modelcontextprotocol/java-sdk
The official Java SDK for Model Context Protocol servers and clients. Maintained in collaboration with Spring AI
What it solves
It provides a standardized way for Java applications to integrate with the Model Context Protocol (MCP), allowing them to interact with AI models and tools through a consistent interface. This removes the need for developers to build custom integration logic for every different AI tool or model they wish to connect to.
How it works
The SDK implements the MCP specification using a modular architecture that supports both synchronous and asynchronous communication. It uses Reactive Streams (via Project Reactor) to handle the bidirectional, non-blocking nature of the protocol, while providing a synchronous facade for simpler use cases. For data handling, it uses Jackson for JSON serialization and the JDK HttpClient for default client transport, while utilizing Jakarta Servlet for server-side transport.
Who it’s for
Java developers building AI-powered applications who need to implement MCP clients (to consume AI services) or MCP servers (to expose their own tools and data to AI models).
Highlights
- Flexible Programming Model: Supports both reactive streaming for high-performance async needs and a synchronous API for simplicity.
- Modular Design: Separates core logic from JSON binding and transport implementations, allowing developers to include only the necessary components.
- Spring AI Integration: Extends the SDK with Spring Boot starters, annotation-based method handling, and OAuth 2.0/API key security.
- Transport Agnostic: Includes default support for STDIO, JDK HttpClient, and Servlets, but remains open to other implementations like Netty or Vert.x.
Related
- Project
- Project
- Project
- Project
- Project