Skip to content

fix: Streamable HTTP Accept negotiation handling#3153

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

fix: Streamable HTTP Accept negotiation handling#3153
dchou1618 wants to merge 3 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
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.

Fix Streamable HTTP Accept header quality-factor handling

1 participant