Skip to content

fix: Streamable HTTP Accept negotiation handling - #3153

Closed
dchou1618 wants to merge 4 commits into
modelcontextprotocol:mainfrom
dchou1618:fix/accept_header
Closed

dchou1618 wants to merge 4 commits into
modelcontextprotocol:mainfrom
dchou1618:fix/accept_header

Conversation

@dchou1618

@dchou1618 dchou1618 commented Jul 23, 2026 •

Copy link
Copy Markdown

Summary

Fixes #3154

This change fixes a protocol-handling issue in the SDK’s Streamable HTTP transport.

Some clients send Accept headers that include q=0 entries for unsupported media types. Previously, the server could still treat those values as acceptable, even though RFC 7231 specifies that q=0 means “not acceptable.” This patch correctly parses Accept header quality values and rejects media types with q=0 as expected.

Motivation and Context

The previous logic only looked for the presence of supported media types in the Accept header and did not honor quality values. As a result, clients could be accepted even when they explicitly declared that a response type was unacceptable. This change makes negotiation more standards-compliant and prevents mismatches between client intent and server behavior.

How Has This Been Tested?

I added regression tests covering:

  • Accept header handling with q=0
  • cases where unsupported media types are explicitly marked as unacceptable

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
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

The change is implemented in src/mcp/server/streamable_http.py, and regression coverage was added in tests/shared/test_streamable_http.py.

@dchou1618 dchou1618 changed the title fix: Streamable HTTP Accept negotiation and transport security header matching fix: Streamable HTTP Accept negotiation handling Jul 23, 2026
@maxisbey

maxisbey commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Thanks for the PR, and sorry it sat here without a proper review.

We're closing most of the open PR backlog. v2 is out and changed a lot of the SDK, so many older PRs no longer apply as written, and we're a small team that realistically doesn't have the capacity to work through the rest.

If this still matters to you on v2, the most useful thing you can do is open an issue (or comment on the existing one) with your use case and a repro. Hearing why it matters to you is what we use to decide what to prioritise.

AI Disclaimer

@maxisbey maxisbey closed this Oct 5, 2026
@maxisbey maxisbey added the missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md) label Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix Streamable HTTP Accept header quality-factor handling

2 participants