|
2 | 2 |
|
3 | 3 | ## Summary |
4 | 4 |
|
5 | | -The Java SDK has been validated against the official MCP conformance test suite for both server and client implementations. |
6 | | - |
7 | | -### Server Tests |
8 | | -Out of 40 total test checks in the "active" suite, **36 passed (90%)** and **4 failed (10%)**. |
9 | | - |
10 | | -### Client Tests |
11 | | -The client conformance implementation supports 4 core scenarios (excluding auth): |
12 | | -- ✅ initialize |
13 | | -- ✅ tools_call |
14 | | -- ✅ elicitation-sep1034-client-defaults |
15 | | -- ✅ sse-retry |
16 | | - |
17 | | -## Client Test Results |
18 | | - |
19 | | -### ✅ Implemented Client Scenarios (4/4) |
20 | | - |
21 | | -#### 1. initialize |
22 | | -**Status:** ✅ Implemented |
23 | | -**Description:** Tests the MCP client initialization handshake |
24 | | -**Validates:** |
25 | | -- Protocol version negotiation |
26 | | -- Client info (name and version) |
27 | | -- Server capabilities handling |
28 | | -- Proper connection establishment and closure |
29 | | - |
30 | | -#### 2. tools_call |
31 | | -**Status:** ✅ Implemented |
32 | | -**Description:** Tests tool discovery and invocation |
33 | | -**Validates:** |
34 | | -- Client initialization |
35 | | -- Listing available tools from server |
36 | | -- Calling the `add_numbers` tool with arguments (a=5, b=3) |
37 | | -- Processing tool results |
38 | | - |
39 | | -#### 3. elicitation-sep1034-client-defaults |
40 | | -**Status:** ✅ Implemented |
41 | | -**Description:** Tests that client applies default values for omitted elicitation fields (SEP-1034) |
42 | | -**Validates:** |
43 | | -- Client properly applies default values from JSON schema |
44 | | -- Supports string, integer, number, enum, and boolean defaults |
45 | | -- Correctly handles elicitation requests from server |
46 | | -- Sends complete responses with all required fields |
47 | | - |
48 | | -#### 4. sse-retry |
49 | | -**Status:** ✅ Implemented |
50 | | -**Description:** Tests client respects SSE retry field timing and reconnects properly (SEP-1699) |
51 | | -**Validates:** |
52 | | -- Client reconnects after SSE stream closure |
53 | | -- Respects the retry field timing (waits specified milliseconds) |
54 | | -- Sends Last-Event-ID header on reconnection |
55 | | -- Handles graceful stream closure as reconnectable |
56 | | - |
57 | | -### Client Implementation Details |
58 | | - |
59 | | -The client conformance tests use: |
60 | | -- **Transport:** `HttpClientStreamableHttpTransport` (JDK HTTP Client) |
61 | | -- **Client Type:** `McpAsyncClient` with reactive (Reactor) API |
62 | | -- **Configuration:** 30-second request timeout, test-client/1.0.0 identification |
63 | | -- **Protocol:** Latest Streamable HTTP protocol (2025-03-26) |
64 | | - |
65 | | -### Running Client Tests |
66 | | - |
67 | | -Build the executable JAR: |
68 | | -```bash |
69 | | -cd conformance-tests/client-jdk-http-client |
70 | | -../../mvnw clean package -DskipTests |
71 | | -``` |
72 | | - |
73 | | -Run with conformance framework: |
74 | | -```bash |
75 | | -npx @modelcontextprotocol/conformance client \ |
76 | | - --command "java -jar conformance-tests/client-jdk-http-client/target/client-jdk-http-client-0.18.0-SNAPSHOT.jar" \ |
77 | | - --scenario initialize |
78 | | - |
79 | | -npx @modelcontextprotocol/conformance client \ |
80 | | - --command "java -jar conformance-tests/client-jdk-http-client/target/client-jdk-http-client-0.18.0-SNAPSHOT.jar" \ |
81 | | - --scenario tools_call |
82 | | - |
83 | | -npx @modelcontextprotocol/conformance client \ |
84 | | - --command "java -jar conformance-tests/client-jdk-http-client/target/client-jdk-http-client-0.18.0-SNAPSHOT.jar" \ |
85 | | - --scenario elicitation-sep1034-client-defaults |
86 | | - |
87 | | -npx @modelcontextprotocol/conformance client \ |
88 | | - --command "java -jar conformance-tests/client-jdk-http-client/target/client-jdk-http-client-0.18.0-SNAPSHOT.jar" \ |
89 | | - --scenario sse-retry |
90 | | -``` |
91 | | - |
92 | | -### Excluded Scenarios |
93 | | - |
94 | | -**Auth Scenarios:** Authentication-related scenarios were excluded as per requirements. The conformance framework includes 15+ auth scenarios that test OAuth2, OIDC, and various authentication flows. These can be added in future iterations. |
| 5 | +**Server Tests:** 37/40 passed (92.5%) |
| 6 | +**Client Tests:** 3/4 scenarios passed (9/10 checks passed) |
95 | 7 |
|
96 | 8 | ## Server Test Results |
97 | 9 |
|
98 | | -### ✅ Passing Tests (36/40) |
99 | | - |
100 | | -#### Lifecycle & Utilities |
101 | | -- ✅ server-initialize: Server initialization handshake |
102 | | -- ✅ logging-set-level: Logging level configuration |
103 | | -- ✅ ping: Server health check |
104 | | -- ✅ completion-complete: Argument autocompletion |
105 | | - |
106 | | -#### Tools (10/11) |
107 | | -- ✅ tools-list: List available tools |
108 | | -- ✅ tools-call-simple-text: Simple text response |
109 | | -- ✅ tools-call-image: Image content response |
110 | | -- ✅ tools-call-audio: Audio content response |
111 | | -- ✅ tools-call-embedded-resource: Embedded resource response |
112 | | -- ✅ tools-call-mixed-content: Multiple content types |
113 | | -- ✅ tools-call-with-logging: Log messages during execution |
114 | | -- ✅ tools-call-error: Error handling |
115 | | -- ❌ tools-call-with-progress: Progress notifications (FAILING) |
116 | | -- ✅ tools-call-sampling: LLM sampling requests |
117 | | -- ✅ tools-call-elicitation: User input requests |
118 | | - |
119 | | -#### Elicitation (10/10) |
120 | | -- ✅ elicitation-sep1034-defaults: Default values for primitive types (5 checks) |
121 | | - - String defaults |
122 | | - - Integer defaults |
123 | | - - Number defaults |
124 | | - - Enum defaults |
125 | | - - Boolean defaults |
126 | | -- ✅ elicitation-sep1330-enums: Enum schema improvements (5 checks) |
127 | | - - Untitled single-select |
128 | | - - Titled single-select |
129 | | - - Legacy enumNames |
130 | | - - Untitled multi-select |
131 | | - - Titled multi-select |
132 | | - |
133 | | -#### SSE Transport |
134 | | -- ✅ server-sse-multiple-streams: Multiple SSE connections (2 checks) |
135 | | - |
136 | | -#### Resources (4/6) |
137 | | -- ✅ resources-list: List available resources |
138 | | -- ✅ resources-read-text: Read text resources |
139 | | -- ✅ resources-read-binary: Read binary resources |
140 | | -- ✅ resources-templates-read: Resource templates |
141 | | -- ❌ resources-subscribe: Subscribe to resources (SDK LIMITATION) |
142 | | -- ❌ resources-unsubscribe: Unsubscribe from resources (SDK LIMITATION) |
143 | | - |
144 | | -#### Prompts (4/4) |
145 | | -- ✅ prompts-list: List available prompts |
146 | | -- ✅ prompts-get-simple: Simple prompts |
147 | | -- ✅ prompts-get-with-args: Parameterized prompts |
148 | | -- ✅ prompts-get-embedded-resource: Prompts with embedded resources |
149 | | -- ✅ prompts-get-with-image: Prompts with images |
150 | | - |
151 | | -#### Security (1/2) |
152 | | -- ✅ dns-rebinding-protection: Localhost host validation |
153 | | -- ❌ dns-rebinding-protection: Non-localhost host rejection (FAILING) |
| 10 | +### Passing (37/40) |
154 | 11 |
|
155 | | -### ❌ Failing Tests (4/40) |
| 12 | +- **Lifecycle & Utilities (4/4):** initialize, ping, logging-set-level, completion-complete |
| 13 | +- **Tools (11/11):** All scenarios including progress notifications ✨ |
| 14 | +- **Elicitation (10/10):** SEP-1034 defaults (5 checks), SEP-1330 enums (5 checks) |
| 15 | +- **Resources (4/6):** list, read-text, read-binary, templates-read |
| 16 | +- **Prompts (4/4):** list, simple, with-args, embedded-resource, with-image |
| 17 | +- **SSE Transport (2/2):** Multiple streams |
| 18 | +- **Security (1/2):** Localhost validation passes |
156 | 19 |
|
157 | | -#### 1. tools-call-with-progress |
158 | | -**Status:** Request timeout |
159 | | -**Issue:** Progress notifications are not being delivered correctly. The tool handler sends progress notifications but the client times out waiting for the response. |
160 | | -**Root Cause:** Potential issue with the Reactor Mono chain not properly handling progress notifications in the async exchange. |
161 | | -**Recommendation:** Requires investigation of the `McpAsyncServerExchange.progressNotification()` implementation and the underlying transport's notification delivery mechanism. |
| 20 | +### Failing (3/40) |
162 | 21 |
|
163 | | -#### 2. resources-subscribe |
164 | | -**Status:** Method not found |
165 | | -**Issue:** The `resources/subscribe` endpoint is not implemented in the Java SDK. |
166 | | -**Root Cause:** The MCP Java SDK does not currently implement server-side subscription handlers. The subscription capability can be advertised but the actual subscribe/unsubscribe request handlers are missing from `McpStatelessAsyncServer`. |
167 | | -**Recommendation:** This is a known SDK limitation. The subscription feature needs to be implemented at the SDK level to handle client subscription requests and track subscribed resources. |
| 22 | +1. **resources-subscribe** - Not implemented in SDK |
| 23 | +2. **resources-unsubscribe** - Not implemented in SDK |
| 24 | +3. **dns-rebinding-protection** - Missing Host/Origin validation (1/2 checks) |
168 | 25 |
|
169 | | -#### 3. resources-unsubscribe |
170 | | -**Status:** Method not found |
171 | | -**Issue:** The `resources/unsubscribe` endpoint is not implemented in the Java SDK. |
172 | | -**Root Cause:** Same as resources-subscribe above. |
173 | | -**Recommendation:** Same as resources-subscribe above. |
174 | | - |
175 | | -#### 4. dns-rebinding-protection (partial) |
176 | | -**Status:** Security validation failure |
177 | | -**Issue:** The server accepts requests with non-localhost Host/Origin headers when it should reject them with HTTP 4xx. |
178 | | -**Root Cause:** The `HttpServletStreamableServerTransportProvider` does not validate Host/Origin headers to prevent DNS rebinding attacks. |
179 | | -**Recommendation:** Add Host/Origin header validation at the transport provider level. This is a security feature that should be implemented in the SDK core, not in individual server implementations. |
180 | | - |
181 | | -## Changes Made |
182 | | - |
183 | | -### Client Conformance Implementation |
184 | | - |
185 | | -#### 1. Base Client Scenarios |
186 | | -- Implemented `initialize` scenario for basic handshake testing |
187 | | -- Implemented `tools_call` scenario for tool discovery and invocation |
188 | | - |
189 | | -#### 2. Elicitation Defaults (SEP-1034) |
190 | | -- Implemented `elicitation-sep1034-client-defaults` scenario |
191 | | -- Tests client properly applies default values from JSON schema |
192 | | -- Validates all primitive types: string, integer, number, enum, boolean |
193 | | - |
194 | | -#### 3. SSE Retry Handling (SEP-1699) |
195 | | -- Implemented `sse-retry` scenario |
196 | | -- Tests client respects retry field timing |
197 | | -- Validates graceful reconnection with Last-Event-ID header |
| 26 | +## Client Test Results |
198 | 27 |
|
199 | | -### Server Conformance Implementation |
| 28 | +### Passing (3/4 scenarios, 9/10 checks) |
200 | 29 |
|
201 | | -#### 1. Added Completion Support |
202 | | -- Enabled `completions` capability in server capabilities |
203 | | -- Implemented completion handler for `test_prompt_with_arguments` prompt |
204 | | -- Returns minimal completion with required `total` field set to 0 |
| 30 | +- **initialize (1/1):** Protocol negotiation, clientInfo, capabilities |
| 31 | +- **tools_call (1/1):** Tool discovery and invocation |
| 32 | +- **elicitation-sep1034-client-defaults (5/5):** Default values for string, integer, number, enum, boolean |
205 | 33 |
|
206 | | -#### 2. Added SEP-1034 Elicitation Defaults Tool |
207 | | -- Implemented `test_elicitation_sep1034_defaults` tool |
208 | | -- Supports default values for all primitive types: |
209 | | - - String: "John Doe" |
210 | | - - Integer: 30 |
211 | | - - Number: 95.5 |
212 | | - - Enum: "active" (from ["active", "inactive", "pending"]) |
213 | | - - Boolean: true |
| 34 | +### Partially Passing (1/4 scenarios, 1/2 checks) |
214 | 35 |
|
215 | | -#### 3. Added SEP-1330 Enum Schema Improvements Tool |
216 | | -- Implemented `test_elicitation_sep1330_enums` tool |
217 | | -- Supports all 5 enum variants: |
218 | | - - Untitled single-select (enum array) |
219 | | - - Titled single-select (oneOf with const/title) |
220 | | - - Legacy enumNames (deprecated) |
221 | | - - Untitled multi-select (array with items.enum) |
222 | | - - Titled multi-select (array with items.anyOf) |
| 36 | +- **sse-retry (1/2 + 1 warning):** |
| 37 | + - ✅ Reconnects after stream closure |
| 38 | + - ❌ Does not respect retry timing |
| 39 | + - ⚠️ Does not send Last-Event-ID header (SHOULD requirement) |
223 | 40 |
|
224 | | -#### 4. Enabled Resources Capability |
225 | | -- Added `resources(true, false)` to server capabilities |
226 | | -- Enables subscribe capability (though not fully implemented in SDK) |
| 41 | +**Issue:** Client treats `retry:` SSE field as invalid instead of parsing it for reconnection timing. |
227 | 42 |
|
228 | 43 | ## Known Limitations |
229 | 44 |
|
230 | | -### 1. Resource Subscriptions Not Implemented |
231 | | -The Java SDK does not implement the server-side handlers for: |
232 | | -- `resources/subscribe` |
233 | | -- `resources/unsubscribe` |
234 | | - |
235 | | -These methods return "Method not found" errors. This is a gap in the SDK that needs to be addressed at the framework level. |
236 | | - |
237 | | -### 2. Progress Notifications Issue |
238 | | -There appears to be an issue with how progress notifications are delivered in the async tool execution flow. The test times out even though the tool handler attempts to send progress notifications correctly. |
239 | | - |
240 | | -### 3. DNS Rebinding Protection Missing |
241 | | -The HTTP transport does not validate Host/Origin headers, making localhost servers vulnerable to DNS rebinding attacks. This security feature should be implemented in the SDK's transport layer. |
242 | | - |
243 | | -## Recommendations |
244 | | - |
245 | | -### For SDK Maintainers |
246 | | - |
247 | | -1. **Implement Resource Subscriptions**: Add handlers for `resources/subscribe` and `resources/unsubscribe` methods in `McpStatelessAsyncServer` and `McpAsyncServer`. Track subscribed resources and implement notification mechanisms. |
248 | | - |
249 | | -2. **Fix Progress Notifications**: Investigate why progress notifications sent via `exchange.progressNotification()` are not being delivered correctly in the SSE transport. The Reactor chain may need adjustment. |
250 | | - |
251 | | -3. **Add DNS Rebinding Protection**: Implement Host/Origin header validation in `HttpServletStreamableServerTransportProvider` to reject requests with non-localhost headers (return HTTP 403). |
| 45 | +1. **Resource Subscriptions:** SDK doesn't implement `resources/subscribe` and `resources/unsubscribe` handlers |
| 46 | +2. **Client SSE Retry:** Client doesn't parse or respect the `retry:` field, reconnects immediately, and doesn't send Last-Event-ID header |
| 47 | +3. **DNS Rebinding Protection:** Missing Host/Origin header validation in server transport |
252 | 48 |
|
253 | | -4. **Document Limitations**: Update SDK documentation to clearly state which MCP features are fully implemented and which have known limitations. |
254 | | - |
255 | | -### For Server Implementations |
256 | | - |
257 | | -1. **Use Latest SDK**: Ensure you're using the latest version of the Java SDK as features are being actively developed. |
258 | | - |
259 | | -2. **Handle Timeouts**: Be aware of the 30-second default request timeout and adjust if needed for long-running operations. |
260 | | - |
261 | | -3. **Security**: If deploying localhost servers, be aware of the DNS rebinding vulnerability until it's addressed in the SDK. |
262 | | - |
263 | | -## Testing Instructions |
264 | | - |
265 | | -### Server Tests |
266 | | - |
267 | | -To reproduce server tests: |
| 49 | +## Running Tests |
268 | 50 |
|
| 51 | +### Server |
269 | 52 | ```bash |
270 | | -# Start the conformance server |
| 53 | +# Start server |
271 | 54 | cd conformance-tests/server-servlet |
272 | 55 | ../../mvnw compile exec:java -Dexec.mainClass="io.modelcontextprotocol.conformance.server.ConformanceServlet" |
273 | 56 |
|
274 | | -# In another terminal, run conformance tests |
| 57 | +# Run tests (in another terminal) |
275 | 58 | npx @modelcontextprotocol/conformance server --url http://localhost:8080/mcp --suite active |
276 | 59 | ``` |
277 | 60 |
|
278 | | -To test individual server scenarios: |
279 | | - |
280 | | -```bash |
281 | | -npx @modelcontextprotocol/conformance server --url http://localhost:8080/mcp --scenario tools-call-with-progress --verbose |
282 | | -``` |
283 | | - |
284 | | -### Client Tests |
285 | | - |
286 | | -To test client scenarios: |
287 | | - |
| 61 | +### Client |
288 | 62 | ```bash |
289 | | -# Build the client JAR first |
| 63 | +# Build |
290 | 64 | cd conformance-tests/client-jdk-http-client |
291 | 65 | ../../mvnw clean package -DskipTests |
292 | 66 |
|
293 | | -# Run individual scenarios |
294 | | -npx @modelcontextprotocol/conformance client \ |
295 | | - --command "java -jar target/client-jdk-http-client-0.18.0-SNAPSHOT.jar" \ |
296 | | - --scenario initialize \ |
297 | | - --verbose |
298 | | - |
299 | | -# Test all client scenarios |
| 67 | +# Run all scenarios |
300 | 68 | for scenario in initialize tools_call elicitation-sep1034-client-defaults sse-retry; do |
301 | 69 | npx @modelcontextprotocol/conformance client \ |
302 | 70 | --command "java -jar target/client-jdk-http-client-0.18.0-SNAPSHOT.jar" \ |
303 | 71 | --scenario $scenario |
304 | 72 | done |
305 | 73 | ``` |
306 | 74 |
|
307 | | -## Conclusion |
308 | | - |
309 | | -The Java SDK conformance implementation demonstrates strong compatibility with the MCP specification, achieving 90% test pass rate. The failing tests represent known limitations that require SDK-level fixes rather than implementation issues in the conformance server itself. |
| 75 | +## Recommendations |
310 | 76 |
|
311 | | -The implementation successfully covers: |
312 | | -- ✅ All core protocol features (initialization, ping, logging) |
313 | | -- ✅ Complete tools API (11 different tool scenarios) |
314 | | -- ✅ Complete prompts API (4 scenarios) |
315 | | -- ✅ Basic resources API (4/6 scenarios) |
316 | | -- ✅ Advanced elicitation features (2 SEPs with 10 sub-tests) |
317 | | -- ✅ Completion/autocompletion support |
318 | | -- ✅ SSE transport with multiple streams |
| 77 | +### High Priority |
| 78 | +1. Fix client SSE retry field handling in `HttpClientStreamableHttpTransport` |
| 79 | +2. Implement resource subscription handlers in `McpStatelessAsyncServer` |
319 | 80 |
|
320 | | -Priority areas for improvement: |
321 | | -1. Resource subscription mechanism (SDK gap) |
322 | | -2. Progress notification delivery (SDK bug) |
323 | | -3. DNS rebinding protection (security feature) |
| 81 | +### Medium Priority |
| 82 | +3. Add Host/Origin validation in `HttpServletStreamableServerTransportProvider` for DNS rebinding protection |
0 commit comments