Skip to content

fix(server): validate exact Accept media types - #3228

Open
ProMBZ wants to merge 8 commits into
modelcontextprotocol:mainfrom
ProMBZ:fix/2480-parse-accept-media-ranges
Open

ProMBZ wants to merge 8 commits into
modelcontextprotocol:mainfrom
ProMBZ:fix/2480-parse-accept-media-ranges

Conversation

@ProMBZ

@ProMBZ ProMBZ commented Nov 23, 2026

Copy link
Copy Markdown

Fixes #2480

Problem

The Streamable HTTP transport used substring checks on the raw Accept header. Values such as application/jsonx and text/event-stream-bogus therefore passed negotiation even though they do not list the required media types.

Change

  • Parse each comma-separated Accept media range using the existing shared mediaTypeEssence parser.
  • Ignore parameters and compare the media type case-insensitively.
  • Use exact matching for both POST requirements and the GET SSE requirement.
  • Split list elements without treating commas inside quoted parameter values as separators.

Tests

Adds POST and GET regressions for substring false positives, plus valid case-insensitive parameterized media ranges.

AI assistance disclosure: prepared with AI assistance. Tests have been added but not run in this environment; CI and maintainer review should verify the change.

@ProMBZ
ProMBZ requested a review from a team as a code owner November 23, 2026 07:40
@changeset-bot

changeset-bot Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c61d9b0

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

This PR includes changesets to release 6 packages
Name Type
@modelcontextprotocol/server Patch
@modelcontextprotocol/client Patch
@modelcontextprotocol/codemod Patch
@modelcontextprotocol/core Patch
@modelcontextprotocol/server-legacy Patch
@modelcontextprotocol/core-internal Patch

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

pkg-pr-new Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@3228

@modelcontextprotocol/codemod

npm i https://pkg.pr.new/@modelcontextprotocol/codemod@3228

@modelcontextprotocol/core

npm i https://pkg.pr.new/@modelcontextprotocol/core@3228

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@3228

@modelcontextprotocol/server-legacy

npm i https://pkg.pr.new/@modelcontextprotocol/server-legacy@3228

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@3228

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@3228

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@3228

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@3228

commit: c61d9b0

@claude claude Bot added the v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes label Nov 23, 2026

ProMBZ commented Nov 23, 2026

Copy link
Copy Markdown
Author

I pushed two follow-ups: the Prettier formatting correction and the patch changeset for @modelcontextprotocol/server. Could a maintainer assign a reviewer and let the latest checks complete? The previous run passed the unit, E2E, runtime and conformance jobs; its only failure was Prettier on the changed source file.

This branch has not been deployed

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

Labels

v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Streamable HTTP server accepts invalid media types by Accept-header substring

1 participant