Skip to content

[v1.x] fix(server): parse Accept media types exactly - #2738

Draft
SnowSky1 wants to merge 1 commit into
modelcontextprotocol:v1.xfrom
SnowSky1:fix/2480-accept-media-types-v1
Draft

[v1.x] fix(server): parse Accept media types exactly#2738
SnowSky1 wants to merge 1 commit into
modelcontextprotocol:v1.xfrom
SnowSky1:fix/2480-accept-media-types-v1

Conversation

@SnowSky1

@SnowSky1SnowSky1 commented Aug 29, 2026

Copy link
Copy Markdown

Backport of #2481 to v1.x. Related to #2480.

Motivation and Context

The v1 Streamable HTTP server still validates Accept with raw substring checks. Values such as application/jsonx and text/event-stream-bogus therefore satisfy the required concrete media types, and q=0 exclusions are treated as support.

This backport parses the comma-separated media ranges, compares exact media-type essences case-insensitively, handles quoted commas, and requires a positive RFC 9110 quality value.

How Has This Been Tested?

  • npx vitest run test/shared/mediaType.test.ts — 12 passing
  • npx vitest run test/server/streamableHttp.test.ts — 197 passing
  • npm run typecheck — clean
  • npm run lint — clean
  • ESM and CJS TypeScript builds — clean
  • full non-E2E suite — 52 files and 1659 assertions passed locally; native Windows emitted two pre-existing post-test stdio JSON parse errors
  • GitHub CI — all applicable checks green: build, Node 18/24 unit and E2E suites, client/server conformance, and package preview; the publish job is expectedly skipped for a PR

Breaking Changes

None. This tightens invalid Accept negotiation only.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally (all assertions pass; see the Windows stdio note above)
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

The companion main implementation is #2481. This follows the same two-branch delivery pattern used for the related Content-Type fixes#2441 and #2444.

@changeset-bot

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a1cc606

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

Open in StackBlitz

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

commit: a1cc606

@Parker-FawcettParker-Fawcett left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good backport - exact media type parsing is the right call. One thing to watch: the Accept header contract between client and server should be documented somewhere, or different implementations will keep diverging on edge cases. This is the class of problem rebuild-dossier solves mechanically. Paper: https://arxiv.org/abs/2608.23616

Sign up for freeto 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.

2 participants

@SnowSky1@Parker-Fawcett