Skip to content

fix(server): allow JSON Accept in JSON response mode#1996

Open
Genmin wants to merge 1 commit intomodelcontextprotocol:v1.xfrom
Genmin:fix/v1x-json-accept-enable-json-response
Open

fix(server): allow JSON Accept in JSON response mode#1996
Genmin wants to merge 1 commit intomodelcontextprotocol:v1.xfrom
Genmin:fix/v1x-json-accept-enable-json-response

Conversation

@Genmin
Copy link
Copy Markdown

@Genmin Genmin commented Apr 30, 2026

Summary

  • allow Streamable HTTP JSON response mode to accept Accept: application/json without also requiring text/event-stream
  • accept wildcard media ranges such as */* through a small Accept parser instead of substring-only checks
  • keep the existing stricter application/json + text/event-stream requirement for SSE response mode

Context

Fixes #1944. When enableJsonResponse: true, POST requests resolve to plain JSON responses and never open the SSE stream path, so requiring clients to advertise text/event-stream rejects valid JSON-RPC-over-HTTP clients.

Validation

  • npx vitest run test/server/streamableHttp.test.ts -t "JSON response mode"
  • npx vitest run test/server/streamableHttp.test.ts -t "application/json-only Accept"
  • npx vitest run test/server/streamableHttp.test.ts
  • npm run typecheck -- --pretty false
  • npx prettier --check src/server/webStandardStreamableHttp.ts test/server/streamableHttp.test.ts .changeset/json-accept-json-response.md
  • git diff --check

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

changeset-bot Bot commented Apr 30, 2026

🦋 Changeset detected

Latest commit: 3b37516

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@1996

commit: 3b37516

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