Bug description
The stdio client stops processing responses after receiving either of these malformed JSON-RPC responses:
- A response without jsonrpc
- A response containing both result and error
The SDK logs a validation error, but the affected tool call does not fail immediately. It times out, and a subsequent ping on the same client also times out.
I reproduced both cases three times with SDK 2.0.1. Streamable HTTP rejected the same responses and continued processing requests normally.
This is separate from #1156, where a response with "jsonrpc": "1.0" is accepted.
Environment
- MCP Java SDK: 2.0.1
- Java: 21.0.9
- Maven: 3.9.11
- Protocol version: 2025-11-25
- Client: Synchronous
- Transport: stdio
- Server: mcp-failure-lab@0.11.0
- OS: Linux arm64 container
- Spring AI: Not used
- Vector store: Not applicable
Steps to reproduce
- Initialize a synchronous Java SDK client over stdio.
- Send a tool request.
- Return a response with the matching request ID that either:
- omits jsonrpc, or
- contains both result and error.
- Observe that the tool call times out.
- Call ping on the same client.
- Observe that ping also times out.
For the missing jsonrpc case, the client logs:
Cannot construct instance of io.modelcontextprotocol.spec.McpSchema$JSONRPCResponse:
jsonrpc must not be empty
For the response containing both fields, it logs:
Cannot construct instance of io.modelcontextprotocol.spec.McpSchema$JSONRPCResponse:
MCP responses MUST either have a result or error
Expected behavior
The malformed response should fail its matching request without stopping the stdio client from processing later messages. A subsequent ping should complete normally.
Minimal Complete Reproducible example
The pinned test harness is here:
https://github.com/anilloutombam/mcp-failure-lab/tree/main/experiments/java-sdk
Run it with:
git clone https://github.com/anilloutombam/mcp-failure-lab.git
cd mcp-failure-lab
docker build -t mcp-failure-lab-java-sdk ./experiments/java-sdk
mkdir -p work/java-sdk-results
docker run --rm \
-v "$PWD/work/java-sdk-results:/results" \
mcp-failure-lab-java-sdk
The relevant cases are:
- missing-jsonrpc-recovery
- result-with-error-recovery
Test code:
https://github.com/anilloutombam/mcp-failure-lab/blob/main/experiments/java-sdk/src/main/java/dev/mcplab/JavaSdkCompatibility.java#L93-L100
Full results:
https://github.com/anilloutombam/mcp-failure-lab/blob/main/docs/compatibility/java-sdk-2.0.1.md
Bug description
The stdio client stops processing responses after receiving either of these malformed JSON-RPC responses:
The SDK logs a validation error, but the affected tool call does not fail immediately. It times out, and a subsequent ping on the same client also times out.
I reproduced both cases three times with SDK 2.0.1. Streamable HTTP rejected the same responses and continued processing requests normally.
This is separate from #1156, where a response with "jsonrpc": "1.0" is accepted.
Environment
Steps to reproduce
For the missing jsonrpc case, the client logs:
For the response containing both fields, it logs:
Expected behavior
The malformed response should fail its matching request without stopping the stdio client from processing later messages. A subsequent ping should complete normally.
Minimal Complete Reproducible example
The pinned test harness is here:
https://github.com/anilloutombam/mcp-failure-lab/tree/main/experiments/java-sdk
Run it with:
The relevant cases are:
Test code:
https://github.com/anilloutombam/mcp-failure-lab/blob/main/experiments/java-sdk/src/main/java/dev/mcplab/JavaSdkCompatibility.java#L93-L100
Full results:
https://github.com/anilloutombam/mcp-failure-lab/blob/main/docs/compatibility/java-sdk-2.0.1.md