Skip to content

fix: send SEP-2243 streamable HTTP headers#2724

Closed
he-yufeng wants to merge 1 commit into
modelcontextprotocol:mainfrom
he-yufeng:fix/streamable-http-sep2243-headers
Closed

fix: send SEP-2243 streamable HTTP headers#2724
he-yufeng wants to merge 1 commit into
modelcontextprotocol:mainfrom
he-yufeng:fix/streamable-http-sep2243-headers

Conversation

@he-yufeng

Copy link
Copy Markdown

Summary

  • add SEP-2243 mcp-method headers to streamable HTTP POST requests
  • add mcp-name for tool calls, prompt gets, and resource read/subscribe/unsubscribe requests
  • cover the method/name mapping without changing existing session or protocol-version headers

To verify

  • uv run pytest tests/shared/test_streamable_http.py -q
  • uv run ruff check src/mcp/client/streamable_http.py tests/shared/test_streamable_http.py
  • uv run ruff format --check src/mcp/client/streamable_http.py tests/shared/test_streamable_http.py
  • git diff --check

@he-yufeng he-yufeng force-pushed the fix/streamable-http-sep2243-headers branch from 9ce1a60 to 47e5ddd Compare May 29, 2026 23:50
@he-yufeng he-yufeng force-pushed the fix/streamable-http-sep2243-headers branch from 47e5ddd to 3fdd4b3 Compare June 6, 2026 21:49
@he-yufeng

Copy link
Copy Markdown
Author

Rebased this branch on current main and force-pushed 3fdd4b3.

The rebase conflict was in tests/shared/test_streamable_http.py after upstream converted the protocol-version checks to the in-process async client fixture. I kept the upstream async protocol-version coverage and re-applied this PR's SEP-2243 mcp-method / mcp-name header regression test on top.

Validated locally:

  • uv run --frozen pytest tests/shared/test_streamable_http.py::test_client_includes_protocol_version_header_after_init tests/shared/test_streamable_http.py::test_streamable_http_client_adds_sep_2243_headers tests/shared/test_streamable_http.py::test_server_validates_protocol_version_header tests/shared/test_streamable_http.py::test_server_backwards_compatibility_no_protocol_version -q (11 passed)
  • uv run --frozen ruff check src/mcp/client/streamable_http.py tests/shared/test_streamable_http.py
  • uv run --frozen ruff format --check src/mcp/client/streamable_http.py tests/shared/test_streamable_http.py
  • uv run --frozen pyright src/mcp/client/streamable_http.py tests/shared/test_streamable_http.py (0 errors)
  • python -m py_compile src\mcp\client\streamable_http.py tests\shared\test_streamable_http.py
  • git diff --check --cached before completing the rebase

@he-yufeng

Copy link
Copy Markdown
Author

Closing this — main now sends the SEP-2243 routing headers directly: _per_message_headers() adds Mcp-Method (and Mcp-Name for tools/call) on modern protocol versions, and _prepare_headers() already pins MCP-Protocol-Version on every request. That covers what this PR added, and the in-tree version goes further (e.g. encoding the tool name and leaving room for the prompts/get / resources/read name params). No reason to keep a competing implementation open. Thanks!

@he-yufeng he-yufeng closed this Jun 22, 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.

1 participant