How modelcontextprotocol/java-sdk works
Main Components
• MCP Core Library (located in the “mcp” directory): This is where the essential protocol definitions, clients, servers, transport implementations (HTTP SSE, Stdio, etc.), and utility classes reside.
• MCP BOM (“mcp-bom” directory): Acts as the Bill of Materials to ensure dependency versions and module coordination across the SDK.
• MCP Spring Integration (“mcp-spring” directory): Contains two distinct modules:
– mcp-spring-webflux: Provides non-blocking, reactive connectors (using WebFlux) for both client and server components.
– mcp-spring-webmvc: Provides traditional Spring MVC-based integration, especially for server side provisions.
• Test Components (“mcp-test” directory and tests in other modules): Include a comprehensive suite of tests covering client and server interactions, integration tests, and transport validation.
Relationships and Interactions
• How applications (or external systems) use the MCP Core Library as the central piece to initiate communication with AI models.
• That the Spring integration modules wrap around or extend the core’s functionalities, offering pre-configured starters for those using Spring Boot.
• That the BOM acts as the glue between multiple modules, ensuring consistent dependency management.
• Testing components interacting with the main libraries to validate both synchronous (McpSync…) and asynchronous (McpAsync…) functionalities and various transport mechanisms.
Architectural Patterns and Design Principles
• Modularity: The separation of concerns is evident—core protocol definitions are separated from Spring specific integrations and test suites.
• Extensibility: The use of interfaces and provider patterns (as visible in the transport packages) implies that the SDK is designed for extensibility.
• In the Spring integration modules, differentiate between reactive (WebFlux) and servlet-based (WebMVC) approaches.
Relevant Technologies, Frameworks, or Libraries
• Java SDK (core language and libraries).
• Spring Boot, separating WebFlux and WebMVC for reactive vs. traditional server environments.
• Maven (as evidenced by the pom.xml files, wrapper scripts, and Maven Central related workflows).
• CI/CD integration (GitHub workflows indicate automated builds and releases).
• SSE (Server-Sent Events) implementations for client/server transport.
Final Assembly
• Use sub-divisions for the Spring modules to detail client/server flows.
• Flows with interaction patterns (e.g., “Async Client → Core Protocol → Async Server”).
• Notes for configuration management (via Maven/BOM) and testing that ensures the correctness of these interactions.