modelcontextprotocol/java-sdk

▲ 2 stars today★ 3,715⑂ 1,148

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

About modelcontextprotocol/java-sdk

modelcontextprotocol/java-sdk is an open-source project on GitHub, mainly written in Java. The official Java SDK for Model Context Protocol servers and clients. Maintained in collaboration with Spring AI It currently holds 3,715 stars and 1,148 forks with 0 open issues, and was last pushed on an unknown date (repository created unknown).

Project Overview

AI Homed tracks it on the Today's Trending board, currently at rank #83 with 2 new stars today.

GitHub Repository Details

Repository modelcontextprotocol/java-sdk · default branch - · size 0 KB · watchers 0 · source: GitHub REST API and repository README

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.1-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.1-SNAPSHOT.jar" \ --suite auth

Contributing

Contributions are welcome! Please follow the Contributing Guidelines.

Team

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:

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

2. Programming Model

These requirements call for a programming model more powerful than single-result futures like CompletableFuture. 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. 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. 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.

3. Observability

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

Server Transport in the SDK

Authorization in the SDK

Project Structure of the SDK

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

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.

GitHub Stars & Activity

3,715Stars
1,148Forks
0Open issues
JavaLanguage

GitHub Popularity

GitHub stars3,715
Forks1,148
Open issues0
Primary languageJava
License-
Stars gained today2
Created-
Last pushed-

Trending History

Daily boardrank #83 · ▲ 2 stars

Related AI Projects

1

langchain4j / langchain4j

Java★ 13,183⑂ 2,580▲ 7 stars
→
2

iflytek / skillhub

Java★ 5,195⑂ 846▲ 10 stars
→
3

openclaw / openclaw

TypeScript★ 390,939⑂ 82,214▲ 136 stars
→
4

obra / superpowers

Shell★ 293,410⑂ 26,254▲ 588 stars
→
5

mattpocock / skills

Shell★ 272,865⑂ 22,953▲ 908 stars
→
6

affaan-m / ECC

JavaScript★ 270,120⑂ 40,363▲ 650 stars
→
7

firecrawl / firecrawl

TypeScript★ 187,086⑂ 9,993▲ 579 stars
→
8

msitarzewski / agency-agents

Shell★ 155,492⑂ 25,093▲ 212 stars
→

More AI Rankings