Skip to content

Document per-request HTTP headers for Streamable HTTP clients - #3288

Open
HaoChiBao wants to merge 2 commits into
modelcontextprotocol:mainfrom
HaoChiBao:docs/1966-per-request-http-headers
Open

Document per-request HTTP headers for Streamable HTTP clients#3288
HaoChiBao wants to merge 2 commits into
modelcontextprotocol:mainfrom
HaoChiBao:docs/1966-per-request-http-headers

Conversation

@HaoChiBao

Copy link
Copy Markdown

Summary

  • Documents the existing Client + Streamable HTTP pattern for per-request Authorization / trace headers using contextvars and an httpx2 event_hooks["request"] hook on a shared AsyncClient (docs_src/client_transports/tutorial005.py + section in docs/client/transports.md).
  • No new Client kwargs or public API; this is the docs-only path @Kludex suggested on Per-Request Transport Configuration for MCP Clients #1966.
  • Adds a docs_src test that proves values set around each Client call reach the request hook as headers over in-process Streamable HTTP.

Fixes #1966

AI disclosure

AI-assisted drafting (Cursor). I reviewed the resulting docs/example/tests and verified them locally.

Test plan

  • uv run --frozen ruff format / ruff check --fix on touched files
  • uv run --frozen pyright on touched files
  • uv run --frozen pytest tests/docs_src/test_client_transports.py -v (7 passed)
  • Confirm docs page renders the new --8<-- snippet under Client transports → Per-request headers

Show how contextvars plus an httpx2 request event hook on a shared
AsyncClient cover per-call Authorization and trace headers without new
Client API, addressing modelcontextprotocol#1966.

@cubic-dev-ai cubic-dev-ai Bot 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.

No issues found across 3 files

Re-trigger cubic

Avoid a partial-covered POST-only branch and match the usual
session_manager pragma so fail_under=100 passes.
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.

Per-Request Transport Configuration for MCP Clients

1 participant