Skip to content

Commit 1004e39

Browse files
committed
Document header injection for MCPRemoteProxy
Add documentation for the headerForward field in MCPRemoteProxy CRD, which allows injecting custom headers into requests to remote MCP servers. Covers plaintext headers, secret-backed headers, and combined usage with security considerations.
1 parent 41a54c8 commit 1004e39

1 file changed

Lines changed: 83 additions & 0 deletions

File tree

docs/toolhive/guides-k8s/remote-mcp-proxy.mdx

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,89 @@ spec:
431431
Now the proxy exchanges validated company tokens for remote service tokens
432432
before forwarding requests.
433433

434+
### Inject custom headers
435+
436+
Some remote MCP servers require custom headers for tenant identification, API
437+
keys, or other purposes. Use the `headerForward` field to inject headers into
438+
every request forwarded to the remote server.
439+
440+
For non-sensitive values like tenant IDs or correlation headers, use
441+
`addPlaintextHeaders`:
442+
443+
```yaml {6-9}
444+
spec:
445+
remoteURL: https://mcp.analytics.example.com
446+
# ... other config ...
447+
448+
headerForward:
449+
addPlaintextHeaders:
450+
X-Tenant-ID: 'tenant-123'
451+
X-Correlation-ID: 'corr-abc-def-456'
452+
```
453+
454+
For sensitive values like API keys, reference Kubernetes Secrets using
455+
`addHeadersFromSecret`:
456+
457+
```yaml title="api-key-secret.yaml"
458+
apiVersion: v1
459+
kind: Secret
460+
metadata:
461+
name: api-key-secret
462+
namespace: toolhive-system
463+
type: Opaque
464+
stringData:
465+
api-key: 'your-api-key-value'
466+
---
467+
apiVersion: toolhive.stacklok.dev/v1alpha1
468+
kind: MCPRemoteProxy
469+
metadata:
470+
name: analytics-proxy
471+
namespace: toolhive-system
472+
spec:
473+
remoteURL: https://mcp.analytics.example.com
474+
# ... other config ...
475+
476+
# highlight-start
477+
headerForward:
478+
addHeadersFromSecret:
479+
- headerName: 'X-API-Key'
480+
valueSecretRef:
481+
name: api-key-secret
482+
key: api-key
483+
# highlight-end
484+
```
485+
486+
You can combine plaintext and secret-backed headers:
487+
488+
```yaml {6-14}
489+
spec:
490+
remoteURL: https://mcp.analytics.example.com
491+
# ... other config ...
492+
493+
headerForward:
494+
addPlaintextHeaders:
495+
X-Tenant-ID: 'tenant-123'
496+
X-Request-Source: 'toolhive-proxy'
497+
addHeadersFromSecret:
498+
- headerName: 'X-API-Key'
499+
valueSecretRef:
500+
name: api-key-secret
501+
key: api-key
502+
```
503+
504+
:::warning[Security considerations]
505+
506+
- Plaintext header values are visible via `kubectl get` and `kubectl describe`
507+
commands. For sensitive values (API keys, tokens), always use
508+
`addHeadersFromSecret`.
509+
- Secret-backed header values are resolved at runtime from Kubernetes Secrets
510+
and are never stored in ConfigMaps.
511+
- Certain headers cannot be configured for security reasons, including `Host`,
512+
`Connection`, `Transfer-Encoding`, and proxy-related headers like
513+
`X-Forwarded-For`.
514+
515+
:::
516+
434517
## Quick start example
435518

436519
For testing and development, you can use the public MCP specification server:

0 commit comments

Comments
 (0)