Add configurable HTTP header forwarding#181
Conversation
|
self._forward_headers = {h.lower() for h in (headers or ["Authorization"])} I think adding "Authorization" as default value here has no effect. This set is tested against lower cased strings so that would never match. Also, "Authorization" is added separately Suggest changing to this? self._forward_headers = {h.lower() for h in (headers or [])} Or to this: self._forward_headers = {h.lower() for h in (headers or ["authorization"])} |
|
Just to clarify, The special-case check for testing |
@erpic see @floran-putter 's message Re Authorization backwards compatibility. Can we merge? |
|
On god please merge this 😭 |
Codecov ReportAll modified and coverable lines are covered by tests ✅ 📢 Thoughts on this report? Let us know! |
|
Hey there, please add this to the guide (https://fastapi-mcp.tadata.com/advanced/auth). I'm sure other devs will appreciate this as myself would have some hours ago haha |
Describe your changes
headersargument to FastApiMCP to specify an allow-list for HTTP header forwarding._execute_api_tool, match incoming headers case-insensitive against the allow-list and forward them using their original names."authorization"to"Authorization"and update the existing header-passthrough test accordingly.fastapi_mcp_with_custom_headerandtest_custom_header_passthrough_to_tool_handlerto test custom header passthrough.Issue ticket number and link (if applicable)
Closes #113
Screenshots of the feature / bugfix
Checklist before requesting a review