Skip to content

fix(client): respond when request handlers complete empty - #1125

Open
1fanwang wants to merge 3 commits into
modelcontextprotocol:mainfrom
1fanwang:1fannnw/client-empty-request-response
Open

fix(client): respond when request handlers complete empty#1125
1fanwang wants to merge 3 commits into
modelcontextprotocol:mainfrom
1fanwang:1fannnw/client-empty-request-response

Conversation

@1fanwang

@1fanwang 1fanwang commented Sep 3, 2026

Copy link
Copy Markdown

An asynchronous sampling or elicitation handler can complete without a value.
The client then sends no JSON-RPC response, leaving the server blocked until
its request timeout. The client now returns internal error -32603 with the
original request ID.

Motivation and Context

JSON-RPC requires one response for every request with an ID. This converts an
empty client handler completion into an explicit error while preserving normal
results and handler failures.

Closes #1124

The equivalent server-side paths are covered by
#1099.

How Has This Been Tested?

The regression fails on clean main, passes with this change, and the live MCP
2025-11-25 client elicitation scenario still passes.

git worktree add --detach ../java-sdk-main 39c225e46c51311eaf82192f15b950e421580fb5
git diff 39c225e46c51311eaf82192f15b950e421580fb5..HEAD -- \
  mcp-core/src/test/java/io/modelcontextprotocol/spec/McpClientSessionTests.java \
  | git -C ../java-sdk-main apply -
(cd ../java-sdk-main && ./mvnw -pl mcp-core \
  -Dtest=McpClientSessionTests#testEmptyRequestHandlerSendsErrorResponse test)

./mvnw -pl mcp-core \
  -Dtest=McpClientSessionTests#testEmptyRequestHandlerSendsErrorResponse test
./mvnw -pl mcp-core test
./mvnw -pl conformance-tests/client-jdk-http-client -am package -DskipTests
npx -y @modelcontextprotocol/conformance@0.2.0-alpha.11 client \
  --spec-version 2025-11-25 \
  --command "java -jar conformance-tests/client-jdk-http-client/target/client-jdk-http-client-2.1.0-SNAPSHOT.jar" \
  --scenario elicitation-sep1034-client-defaults \
  --expected-failures ./conformance-tests/conformance-baseline.yml
Raw logs
Before:
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
Expecting actual not to be null
BUILD FAILURE

After:
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS

MCP core:
Tests run: 400, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS

Client conformance:
Passed: 5/5, 0 failed, 0 warnings
OVERALL: PASSED

Breaking Changes

None.

Types of changes

  • Bug fix

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Signed-off-by: 1fanwang <1fannnw@gmail.com>
Signed-off-by: 1fanwang <1fannnw@gmail.com>
Signed-off-by: 1fanwang <1fannnw@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Client request handlers that complete empty send no JSON-RPC response

1 participant