Skip to content

Stdio client stops processing responses after rejecting a malformed response #1157

Description

@anilloutombam

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

  1. Initialize a synchronous Java SDK client over stdio.
  2. Send a tool request.
  3. Return a response with the matching request ID that either:
    • omits jsonrpc, or
    • contains both result and error.
  4. Observe that the tool call times out.
  5. Call ping on the same client.
  6. 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions