Skip to content

Fix Streamable HTTP Accept negotiation#2364

Open
raashish1601 wants to merge 1 commit intomodelcontextprotocol:mainfrom
raashish1601:contributor-15/python-sdk-2349
Open

Fix Streamable HTTP Accept negotiation#2364
raashish1601 wants to merge 1 commit intomodelcontextprotocol:mainfrom
raashish1601:contributor-15/python-sdk-2349

Conversation

@raashish1601
Copy link
Copy Markdown

Summary

  • accept either application/json or text/event-stream for Streamable HTTP POSTs when SSE-capable mode is enabled
  • negotiate JSON only when the client does not accept SSE, while preserving SSE when both media types are allowed
  • cover JSON-only and SSE-only clients in the shared transport tests and keep the race-condition regression focused on truly invalid Accept headers

Fixes #2349

Testing

  • $env:PYTHONPATH='src'; python -m pytest tests/shared/test_streamable_http.py -k "accept_header_validation or accept_header_wildcard or single_media_type_negotiates_response or accept_header_incompatible or json_response_accept_json_only"
  • $env:PYTHONPATH='src'; python -m pytest tests/issues/test_1363_race_condition_streamable_http.py -k invalid_accept_headers
  • $env:PYTHONPATH='src'; python -m pytest tests/shared/test_streamable_http.py -k "test_response or test_json_response or server_backwards_compatibility_no_protocol_version"
  • python -m ruff check src/mcp/server/streamable_http.py tests/shared/test_streamable_http.py tests/issues/test_1363_race_condition_streamable_http.py

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.

Streamable HTTP transport rejects Accept: text/event-stream without application/json

1 participant