- Implement MCP server with async/sync support and builder pattern configuration - Add Server stdio/SSE transport layers with robust error handling - Convert McpClient and McpServer to interfaces for better extensibility - Add sampling capabilities for LLM interactions (text/image) - Implement dynamic root management and runtime tool management - Add comprehensive prompt and resource capabilities - Add support for dynamic root management (add/remove roots at runtime) Architecture Changes - Introduce registration records for tools, resources, and prompts - Improve thread safety with concurrent collections - Enhance resource template handling - Implement builder patterns for Server/Client capabilities - Add support for server capabilities and implementation info Transport Layer: - Implement SseServerTransport with SSE endpoints - Add StdioServerTransport for process-based communication - Reorganize transport packages for better organization - Improve transport error handling and shutdown processes Documentation: - Add detailed MCP reference documentation - Include architecture diagrams and API documentation - Add comprehensive test coverage for all components - Include sample projects demonstrating stdio/SSE transports BREAKING CHANGES: Transport Package Reorganization - Move StdioClientTransport to o.s.ai.mcp.client.transport - Move SseClientTransport to o.s.ai.mcp.client.transport - Move ServerParameters to o.s.ai.mcp.client.transport - StdioClientTransport.errorHandler changed to private with setter method Migration: Use setErrorHandler() method instead of direct field access API Changes - Replace static factory methods with builder pattern - Update ServerCapabilities to use builder pattern - Make StdioClientTransport.errorHandler private with setter - Replace rootsListProvider with direct root management - Remove deprecated static factory methods Resolves #27,#25,#24,#11 Related to #12
91 lines
2.7 KiB
Markdown
91 lines
2.7 KiB
Markdown
# Spring AI MCP Reference Documentation
|
|
|
|
This documentation covers the Spring AI implementation of the Model Context Protocol (MCP) specification. The implementation follows the [official MCP specification](https://spec.modelcontextprotocol.io/specification/).
|
|
|
|
## Component Hierarchy
|
|
|
|
### 1. Transport Layer
|
|
[Transport](ref-transport.md)
|
|
- McpTransport Interface
|
|
- Transport Implementations (SSE, STDIO)
|
|
- Message Serialization/Deserialization
|
|
|
|
### 2. Session Layer
|
|
[Session Management](ref-session.md)
|
|
- McpSession Interface
|
|
- DefaultMcpSession Implementation
|
|
- Uses McpTransport for communication
|
|
|
|
### 3. High-Level Components
|
|
Both components operate at the same level, using McpSession internally:
|
|
|
|
[Client](ref-client.md)
|
|
- McpClient Factory
|
|
- Synchronous and Asynchronous Implementations
|
|
- Client Configuration and Builder Pattern
|
|
|
|
[Server](ref-server.md)
|
|
- McpServer Factory
|
|
- Synchronous and Asynchronous Implementations
|
|
- Server Configuration and Builder Pattern
|
|
|
|
### 4. Supporting Components
|
|
|
|
[Error Handling](ref-errors.md)
|
|
- McpError
|
|
- Error Codes and Handling
|
|
- Exception Hierarchy
|
|
|
|
|
|
## Component Relationships
|
|
|
|
```
|
|
┌─────────────┐ ┌─────────────┐
|
|
│ McpClient │ │ McpServer │
|
|
└─────────────┘ └─────────────┘
|
|
│ │
|
|
└─────────┬────────┘
|
|
│
|
|
┌───────────────┐
|
|
│ McpSession │
|
|
└───────────────┘
|
|
│
|
|
┌───────────────┐
|
|
│ McpTransport │
|
|
└───────────────┘
|
|
```
|
|
|
|
## Package Organization
|
|
|
|
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
|
|
|
|
## Key Features
|
|
|
|
- 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
|