You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
62
+
Our goal is not to prescribe "the one true way," but to provide a reference implementation of the MCP specification that is:
63
+
64
+
***Pragmatic** – makes developers productive quickly
65
+
***Interoperable** – aligns with widely used libraries and practices
66
+
***Pluggable** – allows alternatives where projects prefer different stacks
67
+
***Grounded in team familiarity** – we chose technologies the team can be productive with today, while remaining open to community contributions that broaden the SDK
68
+
69
+
### Key Choices and Considerations
70
+
71
+
The SDK had to make decisions in the following areas:
72
+
73
+
1.**JSON serialization** – mapping between JSON and Java types
74
+
75
+
2.**Programming model** – supporting asynchronous processing, cancellation, and streaming while staying simple for blocking use cases
76
+
77
+
3.**Observability** – logging and enabling integration with metrics/tracing
78
+
79
+
4.**Remote clients and servers** – supporting both consuming MCP servers (client transport) and exposing MCP endpoints (server transport with authorization)
80
+
81
+
The following sections explain what we chose, why it made sense, and how the choices align with the SDK's goals.
82
+
83
+
### 1. JSON Serialization
84
+
85
+
***SDK Choice**: Jackson for JSON serialization and deserialization, behind an SDK abstraction (`mcp-json`)
86
+
87
+
***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.
88
+
89
+
***How we expose it**: Public APIs use a zero-dependency abstraction (`mcp-json`). Jackson is shipped as the default implementation (`mcp-jackson2`), but alternatives can be plugged in.
90
+
91
+
***How it fits the SDK**: This offers a pragmatic default while keeping flexibility for projects that prefer different JSON libraries.
92
+
93
+
### 2. Programming Model
94
+
95
+
***SDK Choice**: Reactive Streams for public APIs, with Project Reactor as the internal implementation and a synchronous facade for blocking use cases
96
+
97
+
***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:
98
+
99
+
* Multiple in-flight requests and responses
100
+
* Notifications that do not expect a reply
101
+
* STDIO transports for inter-process communication using pipes
102
+
* Streaming transports such as Server-Sent Events and Streamable HTTP
103
+
104
+
These requirements call for a programming model more powerful than single-result futures like `CompletableFuture`.
105
+
106
+
***Reactive Streams: the Community Standard**
107
+
108
+
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.
109
+
110
+
***Reactive Streams Implementation**
111
+
112
+
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.
113
+
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.
114
+
115
+
***Synchronous Facade in the SDK**
116
+
117
+
Not all MCP use cases require streaming pipelines. Many scenarios are as simple as "send a request and block until I get the result."
118
+
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.
119
+
120
+
***How it fits the SDK**: This design balances scalability, approachability, and future evolution such as Virtual Threads and Structured Concurrency in upcoming JDKs.
121
+
122
+
### 3. Observability
123
+
124
+
***SDK Choice**: SLF4J for logging; Reactor Context for observability propagation
125
+
126
+
***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.
127
+
128
+
***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.
129
+
130
+
***How it fits the SDK**: This provides reliable logging by default and seamless integration with Micrometer, OpenTelemetry, or similar systems for metrics and tracing.
131
+
132
+
### 4. Remote MCP Clients and Servers
133
+
134
+
MCP supports both clients (applications consuming MCP servers) and servers (applications exposing MCP endpoints). The SDK provides support for both sides.
135
+
136
+
#### Client Transport in the SDK
137
+
138
+
***SDK Choice**: JDK HttpClient (Java 11+) as the default client, with optional Spring WebClient support
139
+
140
+
***Why**: The JDK HttpClient is built-in, portable, and supports streaming responses. This keeps the default lightweight with no extra dependencies. Spring WebClient support is available for Spring-based projects.
141
+
142
+
***How we expose it**: MCP Client APIs are transport-agnostic. The core module ships with JDK HttpClient transport. A Spring module provides WebClient integration.
143
+
144
+
***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.
145
+
146
+
#### Server Transport in the SDK
147
+
148
+
***SDK Choice**: Jakarta Servlet implementation in core, with optional Spring WebFlux and Spring WebMVC providers
149
+
150
+
***Why**: Servlet is the most widely deployed Java server API. WebFlux and WebMVC cover a significant part of the Spring community. Together these provide reach across blocking and non-blocking models.
151
+
152
+
***How we expose it**: Server APIs are transport-agnostic. Core includes Servlet support. Spring modules extend support for WebFlux and WebMVC.
153
+
154
+
***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.
155
+
156
+
#### Authorization in the SDK
157
+
158
+
***SDK Choice**: Pluggable authorization hooks for MCP servers; no built-in implementation
159
+
160
+
***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.
161
+
162
+
***How we expose it**: Authorization is integrated into the server transport layer. The SDK does not include its own authorization system.
163
+
164
+
***How it fits the SDK**: This keeps server-side security ecosystem-neutral, while ensuring applications can plug in their preferred authorization strategy.
165
+
166
+
### Project Structure of the SDK
167
+
168
+
The SDK is organized into modules to separate concerns and allow adopters to bring in only what they need:
*`mcp-jackson2` – Jackson implementation of JSON binding
173
+
*`mcp` – Convenience bundle (core + Jackson)
174
+
*`mcp-test` – Shared testing utilities
175
+
*`mcp-spring` – Spring integrations (WebClient, WebFlux, WebMVC)
176
+
177
+
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.
178
+
179
+
### Future Directions
180
+
181
+
The SDK is designed to evolve with the Java ecosystem. Areas we are actively watching include:
182
+
Concurrency in the JDK – Virtual Threads and Structured Concurrency may simplify the synchronous API story
183
+
57
184
## License
58
185
59
186
This project is licensed under the [MIT License](LICENSE).
0 commit comments