Java MCP SDK

Community
modelcontextprotocol
3.4k starsUpdated 3d ago96/100v1.1.2ยท 8d ago

A Java SDK for integrating applications with Model Context Protocol AI models an

This SDK enables Java applications to interact with AI models and tools through a standardized interface. It supports both synchronous and asynchronous communication patterns for building MCP clients and servers.

What it does

  • This SDK enables Java applications to interact with AI models and tools through a standardized interface.
  • It supports both synchronous and asynchronous communication patterns for building MCP clients and servers.

Best for

Interacting with AI models and toolsImplementing MCP servers in JavaBuilding MCP clients in JavaSpring Boot AI applications
About Java MCP SDK

Java MCP SDK is a MCP server categorised under ai / ml, ai integration, client server, model context protocol. This SDK enables Java applications to interact with AI models and tools through a standardized interface. It supports both synchronous and asynchronous communication patterns for building MCP clients and servers.

How to install

Pick your MCP client from the Install panel on this page to get a one-click install link (Cursor, VS Code) or a ready-to-paste configuration for Claude Desktop, Claude Code, Gemini, Codex, Windsurf, and other MCP-compatible clients. No local setup required for remote servers.

License

Java MCP SDK is released under the MIT license. This is a permissive open-source license, so you can freely use, modify, and distribute it โ€” subject to its terms.

No reviews yet

Be the first to leave a review after using this server in production.

README

Refreshed 6h ago

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:

SuiteResult
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.

Alternatives

Connects LLMs to GIS operations, enabling AI agents to perform geospatial analys

78/100python