Skip to content

Conversation

@jhrozek
Copy link
Contributor

@jhrozek jhrozek commented Jan 21, 2026

This RFC proposes server-side configuration for injecting HTTP headers into requests forwarded to remote MCP servers. Currently, if specific headers need to be sent to remote servers, clients must configure them individually, which is brittle and doesn't scale across different MCP client implementations.

The solution uses a middleware that injects configured header name-value pairs into every request, following the existing token_injection pattern. This provides a single, centralized configuration point for operators.

Affected components:

  • thv proxy command (--remote-forward-headers flag)
  • thv run command for remote URLs (--remote-forward-headers flag)
  • MCPRemoteProxy Kubernetes CRD (headerForward.addHeaders field)

Related: stacklok/toolhive#3316

@jhrozek jhrozek force-pushed the thv-header-passthrough branch from 1c18630 to 43daa19 Compare January 21, 2026 23:27
This RFC proposes server-side configuration for injecting HTTP headers
into requests forwarded to remote MCP servers. Currently, if specific
headers need to be sent to remote servers, clients must configure them
individually, which is brittle and doesn't scale across different MCP
client implementations.

The solution uses a middleware that injects configured header name-value
pairs into every request, following the existing token_injection pattern.
This provides a single, centralized configuration point for operators.

Affected components:
- thv proxy command (--remote-forward-headers flag)
- thv run command for remote URLs (--remote-forward-headers flag)
- MCPRemoteProxy Kubernetes CRD (headerForward.addHeaders field)

Related: stacklok/toolhive#3316
@jhrozek jhrozek force-pushed the thv-header-passthrough branch from 43daa19 to d08fc31 Compare January 22, 2026 22:35
@jhrozek
Copy link
Contributor Author

jhrozek commented Jan 22, 2026

@JAORMX I added a new section that focuses on adding headers with potentially secret value, wdyt?

Copy link
Contributor

@JAORMX JAORMX left a comment

Choose a reason for hiding this comment

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

Left a couple of comments on specific security considerations worth addressing.

…nflict detection

- Add restricted header blocklist (hop-by-hop, identity-spoofing, smuggling vectors)
- Add configuration-time validation for token exchange/injection conflicts
- Update middleware signature to return error on restricted headers
- Update Security Considerations with new mitigations
@jhrozek jhrozek merged commit 80822d5 into main Jan 23, 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