Java Clean Architecture Masterclass

Java Clean Architecture MasterclassNov 20-21

Join

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

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

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:

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

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.

Join libs.tech

...and unlock some superpowers

GitHub

We won't share your data with anyone else.