Python: Add MCPStreamableHTTPTool security guidance for custom http client - #7245
Merged
Conversation
TaoChenOSU
marked this pull request as ready for review
July 21, 2026 20:03
Contributor
There was a problem hiding this comment.
Pull request overview
This PR clarifies security considerations in the MCPStreamableHTTPTool.__init__ docstring (in the Python core MCP integration), specifically around preventing sensitive header leakage when users configure custom httpx.AsyncClient instances and redirects are involved.
Changes:
- Adds explicit guidance warning that attaching sensitive headers directly on a custom
http_clientrequires user-enforced origin scoping to avoid cross-origin redirect leakage. - Clarifies that the built-in
header_providermechanism only injects headers when the request origin (scheme/host/port) matches the configured MCP serverurl. - Reiterates the distinction between safely using
header_providerfor per-call headers vs. setting default client headers.
Contributor
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
giles17
approved these changes
Jul 21, 2026
TaoChenOSU
enabled auto-merge
July 21, 2026 21:46
moonbox3
approved these changes
Jul 22, 2026
This was referenced Jul 23, 2026
This was referenced Jul 27, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation & Context
This pull request updates the documentation for the
__init__method in thepython/packages/core/agent_framework/_mcp.pyfile to clarify security considerations when configuring custom HTTP clients and headers. The main focus is on preventing sensitive header leakage during cross-origin redirects.Security and documentation improvements:
http_client, and clarified that the framework's built-inheader_provideronly attaches headers to requests matching the configured origin. Users must enforce this origin-scoped policy themselves if supplying headers via a custom client.header_providerhook attaches headers only to requests matching the configured origin, and reiterated the need for users to enforce this policy when using custom clients.Description & Review Guide
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.