Skip to content

Add MCP HTTP header passthrough support - #243

Merged
bettercallsaulj merged 7 commits into
mainfrom
feature_token_protect
Jul 8, 2026
Merged

Add MCP HTTP header passthrough support#243
bettercallsaulj merged 7 commits into
mainfrom
feature_token_protect

Conversation

@bettercallsaulj

@bettercallsaulj bettercallsaulj commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

This PR must be merged after #242.

Detail:
Add MCP HTTP header passthrough support (#250)

@github-actions

Copy link
Copy Markdown

❌ Code Formatting Check Failed

Some files in this PR are not properly formatted according to the project's clang-format rules.

To fix this issue:

make format

Then commit and push the changes.

@gophergogo

Copy link
Copy Markdown
Collaborator

@bettercallsaulj thanks for the work, but once again, please log a ticket to explain the origin of this work. Or the PR can't be merged, unless the community is on the same page.

And please change the title to reflect the work properly.

@bettercallsaulj

Copy link
Copy Markdown
Collaborator Author

@bettercallsaulj thanks for the work, but once again, please log a ticket to explain the origin of this work. Or the PR can't be merged, unless the community is on the same page.

And please change the title to reflect the work properly.

Done

@bettercallsaulj
bettercallsaulj force-pushed the fix_tls_issue branch 2 times, most recently from 9ecbf17 to d08091d Compare July 7, 2026 04:04
@bettercallsaulj
bettercallsaulj force-pushed the feature_token_protect branch from 3901ef2 to 2f40053 Compare July 7, 2026 04:20

@dIvYaNshhh dIvYaNshhh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Header passthrough is a useful feature, but as written it allows header/request injection. Please add validation before merging.

Comment thread src/filter/http_codec_filter.cc
Comment thread src/filter/http_codec_filter.cc
Comment thread src/mcp_connection_manager.cc Outdated
Comment thread src/mcp_connection_manager.cc
dIvYaNshhh
dIvYaNshhh previously approved these changes Jul 7, 2026

@dIvYaNshhh dIvYaNshhh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ✅ — all previously raised findings are addressed. Thanks for the thorough fixes.

RahulHere added 7 commits July 8, 2026 17:13
Summary:

- Add default HTTP header storage to MCP client and connection configuration so SDK-created clients can send runtime Authorization headers.

- Add per-request HTTP header overloads for sendRequest, listTools, and callTool so gateway callers can pass the client bearer token through to backend MCP servers.

- Propagate configured and per-request headers into HTTP/SSE and streamable HTTP request formatting, with per-request headers overriding static defaults.

- Preserve generated transport headers such as Host, Content-Type, Content-Length, Accept, Connection, User-Agent, and Cache-Control.
Summary: Validate client-supplied HTTP headers before the codec serializes them so names or values containing CR, LF, or NUL cannot inject extra header lines or smuggle another request. Add regression coverage for CRLF and NUL header injection attempts while preserving valid passthrough headers.
Summary: Treat Transfer-Encoding as a generated HTTP client header so caller-supplied values cannot be serialized alongside the codec's generated Content-Length. Expose the generated-header predicate for reuse and extend header compatibility coverage for the chunked smuggling case.
Summary: Make McpConnectionManager's direct HTTP POST path use the same client header validation and generated-header blocklist as HttpCodecFilter, including Transfer-Encoding filtering. Add a loopback regression that verifies valid headers pass while CRLF, NUL, Content-Length, and Transfer-Encoding headers are omitted on the wire.
Summary: Reset the shared HTTP client header source back to base headers immediately after each connection-manager write so per-request headers such as Authorization cannot leak into later requests. Add regression coverage that a second codec write with a cleared header source does not reuse the previous request's Authorization value.
Summary: Apply formatting updates to the HTTP codec header filtering code and connection manager header regression test after the header safety fixes.
@bettercallsaulj
bettercallsaulj force-pushed the feature_token_protect branch from d088a49 to 0f850c1 Compare July 8, 2026 09:14
@bettercallsaulj
bettercallsaulj changed the base branch from fix_tls_issue to main July 8, 2026 09:14
@bettercallsaulj
bettercallsaulj dismissed dIvYaNshhh’s stale review July 8, 2026 09:14

The base branch was changed.

@bettercallsaulj
bettercallsaulj merged commit 3b2f4da into main Jul 8, 2026
1 check passed
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.

3 participants