This documentation covers the Spring AI implementation of the Model Context Protocol (MCP) specification. The implementation follows the official MCP specification.
- McpTransport Interface
- Transport Implementations (SSE, STDIO)
- Message Serialization/Deserialization
- McpSession Interface
- DefaultMcpSession Implementation
- Uses McpTransport for communication
Both components operate at the same level, using McpSession internally:
- McpClient Factory
- Synchronous and Asynchronous Implementations
- Client Configuration and Builder Pattern
- McpServer Factory
- Synchronous and Asynchronous Implementations
- Server Configuration and Builder Pattern
- McpError
- Error Codes and Handling
- Exception Hierarchy
┌─────────────┐ ┌─────────────┐
│ McpClient │ │ McpServer │
└─────────────┘ └─────────────┘
│ │
└─────────┬────────┘
│
┌───────────────┐
│ McpSession │
└───────────────┘
│
┌───────────────┐
│ McpTransport │
└───────────────┘
The implementation is organized under the org.springframework.ai.mcp
package with the following structure:
org.springframework.ai.mcp.spec
- Core interfaces and classes- McpTransport
- McpSession
- McpSchema
- McpError
org.springframework.ai.mcp.client
- Client implementations- McpClient
- McpAsyncClient
- McpSyncClient
- Client-specific transports
org.springframework.ai.mcp.server
- Server implementations- McpServer
- McpAsyncServer
- McpSyncServer
- Server-specific transports
org.springframework.ai.mcp.util
- Utility classes- Assert
- Utils
- Synchronous and Asynchronous implementations
- Multiple transport options (SSE, STDIO)
- Comprehensive error handling
- Builder pattern for configuration
- Reactive programming support with Project Reactor
- Type-safe message handling
- Resource and prompt management
- Tool discovery and execution
- Change notification system