Skip to content

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

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

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.
@github-actions github-actions Bot added the missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md) label Aug 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for the contribution. This repository only keeps pull requests open when they're linked to an issue that a maintainer has assigned to the author — CONTRIBUTING.md explains why and how we work. This PR has been closed for now because you aren't currently assigned to #1966.

If a maintainer would like this change as a PR from you, they'll assign you to #1966 and this PR will reopen automatically — there's nothing more you need to do. (If you opened the issue, this PR already shows up on its timeline.)

There's no need to open a new PR — this one will be reopened. While it's closed, please push any updates as new commits rather than force-pushing, since GitHub can't reopen a PR whose branch has been rewritten.

Maintainers: reopening this PR, removing the missing-issue-link label, or adding bypass-issue-check bypasses the check.

@github-actions github-actions Bot closed this Aug 17, 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.

Per-Request Transport Configuration for MCP Clients

1 participant