Skip to content

fix(server): preserve id on duplicate initialize errors#868

Merged
devcrocod merged 3 commits into
modelcontextprotocol:mainfrom
jstar0:fix/streamable-http-reject-id
Jul 22, 2026
Merged

fix(server): preserve id on duplicate initialize errors#868
devcrocod merged 3 commits into
modelcontextprotocol:mainfrom
jstar0:fix/streamable-http-reject-id

Conversation

@jstar0

@jstar0 jstar0 commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #866.

Changes

  • Preserve the parsed JSON-RPC request id when Streamable HTTP rejects a duplicate initialize request.
  • Keep pre-parse and transport-level rejection paths unchanged when the request id is not available.
  • Extend the duplicate-initialize regression test to assert the error response id as well as the HTTP status.

Verification

./gradlew :kotlin-sdk-server:jvmTest --tests 'io.modelcontextprotocol.kotlin.sdk.server.StreamableHttpServerTransportTest.second initialization request returns JSON-RPC error with request id'
./gradlew :kotlin-sdk-server:jvmTest --tests 'io.modelcontextprotocol.kotlin.sdk.server.StreamableHttpServerTransportTest'
./gradlew :kotlin-sdk-server:jvmTest
./gradlew :kotlin-sdk-server:ktlintCheck :kotlin-sdk-server:detekt

@devcrocod devcrocod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@devcrocod
devcrocod merged commit b6cb547 into modelcontextprotocol:main Jul 22, 2026
19 checks passed
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.

Streamable HTTP transport omits JSON-RPC id when rejecting parsed requests

2 participants