How spring-projects-experimental/spring-ai-mcp works
Main components
• MCP Core (Java SDK): Represents the heart of the protocol implementation. It includes the primary packages (e.g., org.springframework.ai.mcp) for both client and server functionality, along with shared components (specification classes for sessions, transports, error handling, etc.).
• Transports: There are several transport mechanisms:
– Stdio transports (client & server) for process-based communication.
– HTTP Streaming via SSE with multiple variations:
▪ HttpClientSseClientTransport (SSE client using HttpClient).
▪ HttpServletSseServerTransport (Servlet-based SSE server).
▪ WebFluxSse* (both client and server) – using reactive Spring WebFlux.
▪ WebMvcSse* (server focused) – using Spring MVC’s traditional model.
• Spring Integration Module: The spring-ai-mcp module provides Spring-specific functionality and auto-configuration for integrating MCP into Spring applications.
• Test Modules: These include mcp-test and test resources within mcp, which show how the client/server and transport layers are validated.
Relationships and interactions
• The MCP Core is central, acting as both a client API and server framework. It relies on the protocol specification (with classes such as McpSession and McpSchema) to standardize communication.
• Transports plug into the core to enable different communication channels. For instance, a client can use either HttpClientSseClientTransport or StdioClientTransport to communicate with a corresponding server transport.
• The integrations with Spring (in spring-ai-mcp) illustrate how MCP’s core and transport functionalities are exposed in a Spring-friendly manner (for instance, via auto-configurations and function callback abstractions).
Architectural patterns and design principles to highlight
• Modular design: Modules like mcp, mcp-transport (with sub-modules for WebFlux and WebMvc) and spring-ai-mcp are organized as distinct Maven projects, promoting separation of concerns.
• Transport Abstraction: The design abstracts the underlying transport logic (Stdio, SSE with various implementations), allowing for flexibility in choosing communication protocols.
• Spring Integration: Emphasize how the MCP functionality is wrapped with Spring-friendly components, providing auto-configuration and integration points.
Additional details
• Supporting components like the documentation (mcp-docs) which provides architecture guides, and indicate its relation to the overall design.