Skip to content

fix(server): surface stateless transport reuse errors#1995

Open
Genmin wants to merge 1 commit intomodelcontextprotocol:v1.xfrom
Genmin:fix/v1x-stateless-streamable-http-reuse
Open

fix(server): surface stateless transport reuse errors#1995
Genmin wants to merge 1 commit intomodelcontextprotocol:v1.xfrom
Genmin:fix/v1x-stateless-streamable-http-reuse

Conversation

@Genmin
Copy link
Copy Markdown

@Genmin Genmin commented Apr 30, 2026

Summary

  • return a JSON-RPC error response when a stateless Streamable HTTP transport instance is reused
  • invoke transport.onerror for that reuse error instead of letting the exception become an opaque Hono 500
  • document the v1.x stateless lifecycle expectation on both the Node and WebStandard transports

Context

Addresses the visibility and diagnostics part of #1994. The existing v1.x code intentionally guards against reusing a stateless transport instance; this PR keeps that lifecycle rule, but makes the failure observable and parseable. That turns the current empty/text 500 into the SDK's normal JSON-RPC error shape and calls onerror with the underlying error message.

Validation

  • npx vitest run test/server/streamableHttp.test.ts -t "should return a JSON error when a stateless transport is reused with a pre-parsed body"
  • npx vitest run test/server/streamableHttp.test.ts -t "should call onerror and return JSON when stateless transport is reused"
  • npx vitest run test/server/streamableHttp.test.ts
  • npm run typecheck -- --pretty false
  • npx prettier --check src/server/streamableHttp.ts src/server/webStandardStreamableHttp.ts test/server/streamableHttp.test.ts .changeset/stateless-transport-reuse-error.md
  • git diff --check

@Genmin Genmin requested a review from a team as a code owner April 30, 2026 15:33
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 30, 2026

🦋 Changeset detected

Latest commit: 0c3595b

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 30, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@modelcontextprotocol/sdk@1995

commit: 0c3595b

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.

1 participant