freshcrate
Skin:/
Home > RAG & Memory > java-sdk

java-sdk

The official Java SDK for Model Context Protocol servers and clients. Maintained in collaboration with Spring AI

Why this rank:Strong adoptionRelease freshnessHealthy release cadence

Description

The official Java SDK for Model Context Protocol servers and clients. Maintained in collaboration with Spring AI

README

MCP Java SDK

License Build Status Maven Central Java Version

A set of projects that provide Java SDK integration for the Model Context Protocol. This SDK enables Java applications to interact with AI models and tools through a standardized interface, supporting both synchronous and asynchronous communication patterns.

๐Ÿ“š Reference Documentation

MCP Java SDK documentation

For comprehensive guides and SDK API documentation

Spring AI MCP documentation

Spring AI MCP extends the MCP Java SDK with Spring Boot integration, providing both client and server starters. The MCP Annotations - provides annotation-based method handling for MCP servers and clients in Java. The MCP Security - provides comprehensive OAuth 2.0 and API key-based security support for Model Context Protocol implementations in Spring AI. Bootstrap your AI applications with MCP support using Spring Initializer.

Development

Building from Source

./mvnw clean install -DskipTests

Running Tests

To run the tests you have to pre-install Docker and npx.

./mvnw test

Conformance Tests

The SDK is validated against the MCP conformance test suite at 0.1.15 version. Full details and instructions are in conformance-tests/VALIDATION_RESULTS.md.

Latest results:

Suite Result
Server โœ… 40/40 passed (100%)
Client ๐ŸŸก 3/4 scenarios, 9/10 checks passed
Auth (Spring) ๐ŸŸก 12/14 scenarios fully passing (98.9% checks)

To run the conformance tests locally you need npx installed.

# Server conformance
./mvnw compile -pl conformance-tests/server-servlet -am exec:java
npx @modelcontextprotocol/conformance server --url http://localhost:8080/mcp --suite active

# Client conformance
./mvnw clean package -DskipTests -pl conformance-tests/client-jdk-http-client -am
for scenario in initialize tools_call elicitation-sep1034-client-defaults sse-retry; do
  npx @modelcontextprotocol/conformance client \
    --command "java -jar conformance-tests/client-jdk-http-client/target/client-jdk-http-client-2.0.0-SNAPSHOT.jar" \
    --scenario $scenario
done

# Auth conformance (Spring HTTP Client)
./mvnw clean package -DskipTests -pl conformance-tests/client-spring-http-client -am
npx @modelcontextprotocol/conformance@0.1.15 client \
  --spec-version 2025-11-25 \
  --command "java -jar conformance-tests/client-spring-http-client/target/client-spring-http-client-2.0.0-SNAPSHOT.jar" \
  --suite auth

Contributing

Contributions are welcome! Please follow the Contributing Guidelines.

Team

  • Christian Tzolov
  • Dariusz Jฤ™drzejczyk
  • Daniel Garnier-Moiroux

Links

Architecture and Design Decisions

Introduction

Building a general-purpose MCP Java SDK requires making technology decisions in areas where the JDK provides limited or no support. The Java ecosystem is powerful but fragmented: multiple valid approaches exist, each with strong communities. Our goal is not to prescribe "the one true way," but to provide a reference implementation of the MCP specification that is:

  • Pragmatic โ€“ makes developers productive quickly
  • Interoperable โ€“ aligns with widely used libraries and practices
  • Pluggable โ€“ allows alternatives where projects prefer different stacks
  • Grounded in team familiarity โ€“ we chose technologies the team can be productive with today, while remaining open to community contributions that broaden the SDK

Key Choices and Considerations

The SDK had to make decisions in the following areas:

  1. JSON serialization โ€“ mapping between JSON and Java types

  2. Programming model โ€“ supporting asynchronous processing, cancellation, and streaming while staying simple for blocking use cases

  3. Observability โ€“ logging and enabling integration with metrics/tracing

  4. Remote clients and servers โ€“ supporting both consuming MCP servers (client transport) and exposing MCP endpoints (server transport with authorization)

The following sections explain what we chose, why it made sense, and how the choices align with the SDK's goals.

1. JSON Serialization

  • SDK Choice: Jackson for JSON serialization and deserialization, behind an SDK abstraction (package io.modelcontextprotocol.json in mcp-core)

  • Why: Jackson is widely adopted across the Java ecosystem, provides strong performance and a mature annotation model, and is familiar to the SDK team and many potential contributors.

  • How we expose it: Public APIs use a bundled abstraction. Jackson is shipped as the default implementation (mcp-json-jackson3), but alternatives can be plugged in.

  • How it fits the SDK: This offers a pragmatic default while keeping flexibility for projects that prefer different JSON libraries.

2. Programming Model

  • SDK Choice: Reactive Streams for public APIs, with Project Reactor as the internal implementation and a synchronous facade for blocking use cases

  • Why: MCP builds on JSON-RPC's asynchronous nature and defines a bidirectional protocol on top of it, enabling asynchronous and streaming interactions. MCP explicitly supports:

    • Multiple in-flight requests and responses
    • Notifications that do not expect a reply
    • STDIO transports for inter-process communication using pipes
    • Streaming transports such as Server-Sent Events and Streamable HTTP

    These requirements call for a programming model more powerful than single-result futures like CompletableFuture.

    • Reactive Streams: the Community Standard

      Reactive Streams is a small Java specification that standardizes asynchronous stream processing with backpressure. It defines four minimal interfaces (Publisher, Subscriber, Subscription, and Processor). These interfaces are widely recognized as the standard contract for async, non-blocking pipelines in Java.

    • Reactive Streams Implementation

      The SDK uses Project Reactor as its implementation of the Reactive Streams specification. Reactor is mature, widely adopted, provides rich operators, and integrates well with observability through context propagation. Team familiarity also allowed us to deliver a solid foundation quickly. We plan to convert the public API to only expose Reactive Streams interfaces. By defining the public API in terms of Reactive Streams interfaces and using Reactor internally, the SDK stays standards-based while benefiting from a practical, production-ready implementation.

    • Synchronous Facade in the SDK

      Not all MCP use cases require streaming pipelines. Many scenarios are as simple as "send a request and block until I get the result." To support this, the SDK provides a synchronous facade layered on top of the reactive core. Developers can stay in a blocking model when it's enough, while still having access to asynchronous streaming when needed.

  • How it fits the SDK: This design balances scalability, approachability, and future evolution such as Virtual Threads and Structured Concurrency in upcoming JDKs.

3. Observability

  • SDK Choice: SLF4J for logging; Reactor Context for observability propagation

  • Why: SLF4J is the de facto logging facade in Java, with broad compatibility. Reactor Context enables propagation of observability data such as correlation IDs and tracing state across async boundaries. This ensures interoperability with modern observability frameworks.

  • How we expose it: Public APIs log through SLF4J only, with no backend included. Observability metadata flows through Reactor pipelines. The SDK itself does not ship metrics or tracing implementations.

  • How it fits the SDK: This provides reliable logging by default and seamless integration with Micrometer, OpenTelemetry, or similar systems for metrics and tracing.

4. Remote MCP Clients and Servers

MCP supports both clients (applications consuming MCP servers) and servers (applications exposing MCP endpoints). The SDK provides support for both sides.

Client Transport in the SDK

  • SDK Choice: JDK HttpClient (Java 11+) as the default client

  • Why: The JDK HttpClient is built-in, portable, and supports streaming responses. This keeps the default lightweight with no extra dependencies.

  • How we expose it: MCP Client APIs are transport-agnostic. The core module ships with JDK HttpClient transport. Spring WebClient-based transport is available in Spring AI 2.0+.

  • How it fits the SDK: This ensures all applications can talk to MCP servers out of the box, while allowing richer integration in Spring and other environments.

Server Transport in the SDK

  • SDK Choice: Jakarta Servlet implementation in core

  • Why: Servlet is the most widely deployed Java server API, providing broad reach across blocking and non-blocking models without additional dependencies.

  • How we expose it: Server APIs are transport-agnostic. Core includes Servlet support. Spring WebFlux and WebMVC server transports are available in Spring AI 2.0+.

  • How it fits the SDK: This allows developers to expose MCP servers in the most common Java environments today, while enabling other transport implementations such as Netty, Vert.x, or Helidon.

Authorization in the SDK

  • SDK Choice: Pluggable authorization hooks for MCP servers; no built-in implementation

  • Why: MCP servers must restrict access to authenticated and authorized clients. Authorization needs differ across environments such as Spring Security, MicroProfile JWT, or custom solutions. Providing hooks avoids lock-in and leverages proven libraries.

  • How we expose it: Authorization is integrated into the server transport layer. The SDK does not include its own authorization system.

  • How it fits the SDK: This keeps server-side security ecosystem-neutral, while ensuring applications can plug in their preferred authorization strategy.

Project Structure of the SDK

The SDK is organized into modules to separate concerns and allow adopters to bring in only what they need:

  • mcp-bom โ€“ Dependency versions
  • mcp-core โ€“ Reference implementation (STDIO, JDK HttpClient, Servlet), JSON binding interface definitions
  • mcp-json-jackson2 โ€“ Jackson 2 implementation of JSON binding
  • mcp-json-jackson3 โ€“ Jackson 3 implementation of JSON binding
  • mcp โ€“ Convenience bundle (core + Jackson 3)
  • mcp-test โ€“ Shared testing utilities

Spring integrations (WebClient, WebFlux, WebMVC) are now part of Spring AI 2.0+ (group org.springframework.ai).

For example, a minimal adopter may depend only on mcp (core + Jackson), while a Spring-based application can use the Spring AI mcp-spring-webflux or mcp-spring-webmvc artifacts for deeper framework integration.

Additionally, mcp-test contains integration tests for mcp-core. mcp-core needs a JSON implementation to run full integration tests. Implementations such as mcp-json-jackson3, depend on mcp-core, and therefore cannot be imported in mcp-core for tests. Instead, all integration tests that need a JSON implementation are now in mcp-test, and use jackson3 by default. A jackson2 maven profile allows to run integration tests with Jackson 2, like so:

./mvnw -pl mcp-test -am -Pjackson2 test

Future Directions

The SDK is designed to evolve with the Java ecosystem. Areas we are actively watching include: Concurrency in the JDK โ€“ Virtual Threads and Structured Concurrency may simplify the synchronous API story

License

This project is licensed under the MIT License.

Release History

VersionChangesUrgencyDate
v1.1.2## What's Changed * HttpClientStreamableHttpTransport: handle HTTP 405 by @Kehrlann in https://github.com/modelcontextprotocol/java-sdk/pull/900 **Full Changelog**: https://github.com/modelcontextprotocol/java-sdk/compare/v1.1.1...v1.1.2High4/25/2026
v1.1.1## What's Changed * Remove "Access-control-allow-origin" header in server transports by @srikanthramu and @Kehrlann **Full Changelog**: https://github.com/modelcontextprotocol/java-sdk/compare/v1.1.0...v1.1.1Medium3/27/2026
v1.0.1## What's Changed * Remove "Access-control-allow-origin" header in server transports by @srikanthramu and @Kehrlann **Full Changelog**: https://github.com/modelcontextprotocol/java-sdk/compare/v1.0.0...v1.0.1Medium3/27/2026
v1.1.0## What's Changed * Use dynamic jar discovery for conformance tests by @chemicL in https://github.com/modelcontextprotocol/java-sdk/pull/832 * Add migration notes for 0.18.1 to 1.0.0 update by @chemicL in https://github.com/modelcontextprotocol/java-sdk/pull/828 * Support resource subscriptions by @chemicL in https://github.com/modelcontextprotocol/java-sdk/pull/839 * Add explicit UTF-8 charset to InputStreamReader in StdioServerTransportProvider by @xxxxxxjun in https://github.com/modelcontLow3/13/2026
v1.0.0# MCP Java SDK 1.0.0 We are pleased to announce the **1.0.0 GA release** of the MCP Java SDK โ€” the official Java SDK for Model Context Protocol servers and clients, maintained in collaboration with Spring AI. --- ## Major Features - **MCP Protocol Implementation** โ€” Spec-compliant implementation of the Model Context Protocol, including tools, resources, prompts, sampling, elicitation, and progress tracking. - **Synchronous and Asynchronous APIs** โ€” First-class support for both blockLow2/23/2026
v1.0.0-RC3We are pleased to announce the v1.0.0-RC3 release ๐Ÿš€ marking the beginning of a stable 1.x release line. ## What's Changed * Move mcp-spring-webflux and mcp-spring-webmvc to Spring AI 2.0 by @tzolov in https://github.com/modelcontextprotocol/java-sdk/pull/805 * Remove deprecations from 1.0.0 by @chemicL in https://github.com/modelcontextprotocol/java-sdk/pull/807 * Conformance testing: add auth conformance testing by @Kehrlann in https://github.com/modelcontextprotocol/java-sdk/pull/806 *Low2/22/2026
v0.18.1## What's Changed * Fix and simplification for osgi manifest.mf contents generation - Cherry-picked from main (https://github.com/modelcontextprotocol/java-sdk/commit/159eb964cc6252afb977c7fc8531748d24954784) **Full Changelog**: https://github.com/modelcontextprotocol/java-sdk/compare/v0.18.0...v0.18.1 Low2/19/2026
v0.18.0## What's Changed * fix: Fixed html encoding in javadoc by @ashakirin in https://github.com/modelcontextprotocol/java-sdk/pull/727 * fix: Enable javadoc generation for modules with OSGi metadata by @jonathanhefner in https://github.com/modelcontextprotocol/java-sdk/pull/705 * fix: Support form and url fields in Elicitation capability per 2025-11-25 spec by @rhtnr in https://github.com/modelcontextprotocol/java-sdk/pull/731 * add 2025-11-25 version to ProtocolVersions by @sdelamo in https://gLow2/19/2026
v0.17.2This release: * Addresses mostly the testing infrastructure issues. * Fixes a client-side issue with servers that process client-initiated notifications with a 202 Accepted HTTP Header. **Full Changelog**: https://github.com/modelcontextprotocol/java-sdk/compare/v0.17.1...v0.17.2Low1/22/2026
v0.17.1Bug fix release: **Full Changelog**: https://github.com/modelcontextprotocol/java-sdk/compare/v0.17.0...v0.17.1Low1/8/2026
v0.17.0## What's Changed * Fix experimental client capabilities tests by @Kehrlann in https://github.com/modelcontextprotocol/java-sdk/pull/670 * Fix typo in test name by @mingo1996 in https://github.com/modelcontextprotocol/java-sdk/pull/661 * Client transports: make #protocolVersions() configurable by @Kehrlann in https://github.com/modelcontextprotocol/java-sdk/pull/669 * chore: Spring 5 compatibility by @He-Pin in https://github.com/modelcontextprotocol/java-sdk/pull/649 * Fix the baseUrl is cLow12/4/2025
v0.16.0## What's Changed * feat: enhance error handling with custom error code preservation by @tzolov in https://github.com/modelcontextprotocol/java-sdk/pull/653 * Bump json-schema-validator from 1.5.7 to 2.0.0 by @uarlouski in https://github.com/modelcontextprotocol/java-sdk/pull/660 * fix: JSONRPCResponse JavaDoc by @vorburger in https://github.com/modelcontextprotocol/java-sdk/pull/657 * fix(docs): Remove broken @see link in McpServer.java Javadoc by @hbsjz-swl in https://github.com/modelconteLow11/12/2025
v0.15.0## What's Changed * define explicitely that values should always be included in code completions by @sdelamo in https://github.com/modelcontextprotocol/java-sdk/pull/601 * fix remove name when using @JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION) by @sdelamo in https://github.com/modelcontextprotocol/java-sdk/pull/600 * refactor: change int to Integer for optional numeric fields by @tzolov in https://github.com/modelcontextprotocol/java-sdk/pull/604 * fix: allow additional properties by defauLow10/30/2025
v0.14.1**Full Changelog**: https://github.com/modelcontextprotocol/java-sdk/compare/v0.14.0...v0.14.1Low10/6/2025
v0.14.0## What's Changed * refactor: Improve resource template management and API consistency by @tzolov @pascalconfluent https://github.com/modelcontextprotocol/java-sdk/pull/576 * fix: handle resource not found according to spec by @sdelamo in https://github.com/modelcontextprotocol/java-sdk/pull/567 * feat: add optional lastModified field to Annotations record by @tzolov in https://github.com/modelcontextprotocol/java-sdk/pull/568 * fix: typo MCP_SESSION_ID, keep consistent style with other idenLow10/1/2025
v0.13.1**Full Changelog**: https://github.com/modelcontextprotocol/java-sdk/compare/v0.13.0...v0.13.1Low9/22/2025
v0.13.0# Release Notes ## ๐Ÿš€ Major Features & Enhancements ### Protocol Version Support - **Added MCP protocol version 2025-06-18 support** for streamable-http and stateless transports (#558) - Set MCP_2025_06_18 as upper supported protocol version - Updated LATEST_PROTOCOL_VERSION constant to reflect new upper bound ### Module Restructuring - **Extracted `mcp-core` module** (#557) - **โš ๏ธ BREAKING CHANGE** - Created new `mcp-core` module free of Jackson dependencies - `mcp` modLow9/18/2025
v0.12.1# Release Notes - Skip structured output validation for error tool results (#540) - ensures that when a tool handler returns an error result, the structured output schema validation is skipped, preventing validation failures on error responses that don't conform to the expected output schema. - Add null check for response ID to prevent memory leaks (#509) - The missing null check could lead to memory leaks as pending requests would never be completed when responses lack session IDsLow9/8/2025
v0.12.0# Release Notes ## โ— Breaking Changes - Re-purposed `McpTransportContext` to reuse in server and client packages and made immutable - more details below - Updated `(Async|Sync)HttpRequestCustomizer` class signatures as part of transport context implementation - Users relying on template resources in `resources/list` should migrate to using `resources/templates/list` ## ๐Ÿš€ New Features ### Transport Context Support (#522) - **Added McpTransportContext to MCP Clients** - Provides a unLow9/4/2025
v0.11.3## ๐Ÿ› Bug Fixes ### HTTP Transport Improvements - **Fixed SSE endpoint Content-Type header issue** (#489) - Removed incorrect Content-Type header from GET requests to SSE endpoints - Resolves compatibility issues with MCP servers that validate HTTP headers strictly - Content-Type header is now only included for POST requests as per HTTP specifications - **Added configurable connection timeout** (#511) - Fixed intermittent connection timeout issues in HttpClientStreamableHttpTLow8/26/2025
v0.11.2# Bug Fix Release ### Server-Sent Events (SSE) Improvements - **Enhanced SSE Comment Handling** (#467): Added proper support for SSE comment lines starting with ':' according to SSE specification - Comment lines are now properly ignored during processing - Added debug logging for comment line processing - Improves compatibility with SSE streams that include comment messages ### Error Handling Enhancements - **Handler Exception Support** (#465): Stateless Server Handlers can now Low8/11/2025
v0.11.1# MCP Java SDK Bug-fix Release ## ๐Ÿ”ง Protocol Compatibility & Transport Improvements ### Multi-Protocol Version Support (#444) - **Breaking Change**: Replaced `protocolVersion()` method with `protocolVersions()` returning `List<String>` - Added backward compatibility for MCP servers returning older protocol versions - Streamable HTTP clients now support both `2024-11-05` and `2025-03-26` protocol versions - Introduced `ProtocolVersions` interface with centralized version constants - FLow8/6/2025
v0.11.0# MCP Java SDK Release Notes ## ๐Ÿš€ Major Features ### New Transport Options - **WebMVC and HttpServlet Support** (#432) - Added stateless server transports for Spring WebMVC and servlet-based applications with comprehensive integration tests - **Spring WebMVC Streamable Transport** (#425) - Non-reactive MCP server support with HTTP/SSE transport, session management, and graceful shutdown - **Streamable HTTP Transport** (#420, #290, #292) - Complete HTTP transport abstractions with WebFlLow7/31/2025
v0.10.0# MCP Java SDK Release Notes ## Features - **URI Template Support** (PR #208): Added URI template functionality for MCP resources, allowing dynamic resource URIs with variables in the format `{variableName}`. This enables: - More flexible resource definitions - Automatic extraction of variable values from request URIs - Validation of template arguments in completions - Matching of request URIs against templates - **Completion Feature** (PR #173): Added support for the compleLow5/13/2025
v0.9.0# MCP Java SDK Release Notes ## Breaking Changes โš ๏ธ There is one minor API breaking change that should not cause significant issues: The type of the `McpSchema.JSONRPCNotification` `params` field has been changed from `Map<String, Object>` to `Object`. This affects the signature of the `sendNotification` method in both `McpClientSession` and `McpServerSession` and the signature of the `notifyClients` method in `McpServerTransportProvider`. ## New Features ### Transport Layer Low4/10/2025
v0.8.1# MCP Java SDK Bug Fix Release Fix StdioServerTransportProvider initialization flow #74 Low3/26/2025
v0.8.0# MCP Java SDK Release Notes ## Breaking Changes โš ๏ธ Follow the [0.8.0 Migration Guide](https://github.com/modelcontextprotocol/java-sdk/blob/main/migration-0.8.0.md) for the new API changes. ## Features & Enhancements ### Architecture Improvements - Introduced session-based architecture for MCP server to better handle multiple concurrent client connections (#31) - Added McpServerTransportProvider interface to manage client connections - Introduced exchange objects (McpAsyncServerELow3/21/2025

Dependencies & License Audit

Loading dependencies...

Similar Packages

quarkus-doclingDocling simplifies document processing, parsing diverse formats โ€” including advanced PDF understanding โ€” and providing seamless integrations with the gen AI ecosystem1.3.1
langchain4jLangChain4j is an open-source Java library that simplifies the integration of LLMs into Java applications through a unified API, providing access to popular LLMs and vector databases. It makes impleme1.16.1
MoLiโš™๏ธ Simplify your projects with MoLi, a fast and flexible Molang interpreter in Java, designed for easy integration and high performance.main@2026-06-06
Mini-o3๐Ÿง  Enhance visual search with Mini-o3, providing state-of-the-art multi-turn reasoning and easy-to-use training code for advanced AI applications.main@2026-06-06
awesome-opensource-aiCurated list of the best truly open-source AI projects, models, tools, and infrastructure.main@2026-06-06

More from modelcontextprotocol

python-sdkThe official Python SDK for Model Context Protocol servers and clients
typescript-sdkThe official TypeScript SDK for Model Context Protocol servers and clients
modelcontextprotocolSpecification andย documentation for the Model Context Protocol
registryA community driven registry service for Model Context Protocol (MCP) servers.

More in RAG & Memory

vllmA high-throughput and memory-efficient inference and serving engine for LLMs
spiceaiA portable accelerated SQL query, search, and LLM-inference engine, written in Rust, for data-grounded AI apps and agents.
awesome-opensource-aiCurated list of the best truly open-source AI projects, models, tools, and infrastructure.
antflyNo description