Skip to content

Commit dcc74ba

Browse files
ChrisJBurnsclaude
andcommitted
Address header secret handling in static mode for type: direct
Use SecretKeyRef env vars on the vMCP Deployment instead of inlining secret values into the backend ConfigMap. Mirrors the existing pattern from MCPRemoteProxy. ConfigMap stores only env var names, vMCP resolves values at runtime via secrets.EnvironmentProvider. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8a53d46 commit dcc74ba

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

rfcs/THV-0055-mcpremoteendpoint-unified-remote-backends.md

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ strict YAML parsing. Writing new fields (`Type`, `CABundlePath`, `Headers`)
580580
to the ConfigMap before updating the vMCP binary will cause a startup failure.
581581

582582
Implementation order:
583-
1. Add `Type`, `CABundlePath`, and `Headers` fields to `StaticBackendConfig`
583+
1. Add `Type`, `CABundlePath`, and `HeaderEnvVars` fields to `StaticBackendConfig`
584584
2. Update the vMCP binary and the roundtrip test in
585585
`pkg/vmcp/config/crd_cli_roundtrip_test.go`
586586
3. Deploy the updated vMCP image **before** the operator starts writing these
@@ -589,11 +589,27 @@ Implementation order:
589589
Additional touch points:
590590
- `listMCPRemoteEndpointsAsMap()` — new function for ConfigMap generation
591591
- `getExternalAuthConfigNameFromWorkload()` — add MCPRemoteEndpoint case
592-
- `headerForward.addHeadersFromSecret` requires K8s Secret resolution at
593-
ConfigMap generation time (static mode has no K8s API access at runtime)
594-
- `vmcp.Backend` needs a `Headers` field for resolved header values
595592
- Deployment volume mount logic for `caBundleRef` ConfigMaps
596593

594+
**Header secret handling in static mode:** Secret values MUST NOT be inlined
595+
into the backend ConfigMap. Instead, the operator uses the same `SecretKeyRef`
596+
pattern that MCPRemoteProxy already uses:
597+
598+
1. For each `type: direct` endpoint with `addHeadersFromSecret` entries, the
599+
operator adds `SecretKeyRef` environment variables to the **vMCP Deployment**
600+
(e.g. `TOOLHIVE_SECRET_HEADER_FORWARD_X_API_KEY_<ENDPOINT_NAME>`).
601+
2. The static backend ConfigMap stores only the env var names — never the
602+
secret values themselves.
603+
3. At runtime, vMCP resolves header values via the existing
604+
`secrets.EnvironmentProvider`, identical to how MCPRemoteProxy pods handle
605+
this today.
606+
607+
This ensures no key material is written to ConfigMaps or stored in etcd in
608+
plaintext. The trade-off is that adding or removing `addHeadersFromSecret`
609+
entries on a direct endpoint triggers a vMCP Deployment update (and therefore
610+
a pod restart), consistent with how CA bundle changes already behave in static
611+
mode.
612+
597613
**CA bundle in static mode:** The operator mounts the `caBundleRef` ConfigMap
598614
as a volume into the vMCP pod at `/etc/toolhive/ca-bundles/<endpoint-name>/ca.crt`.
599615
The generated backend ConfigMap includes the mount path so vMCP can construct
@@ -904,11 +920,13 @@ can manage backends) and couples backend lifecycle to vMCP reconciliation.
904920

905921
### Phase 2: Static Mode Integration
906922

907-
1. Add `Type`, `CABundlePath`, `Headers` fields to `StaticBackendConfig`;
923+
1. Add `Type`, `CABundlePath`, `HeaderEnvVars` fields to `StaticBackendConfig`;
908924
update vMCP binary and roundtrip test BEFORE operator starts writing them
909925
2. Update VirtualMCPServer controller: `listMCPRemoteEndpointsAsMap()`,
910926
`getExternalAuthConfigNameFromWorkload()`, ConfigMap generation
911-
3. Implement header secret resolution at ConfigMap generation time
927+
3. Add `SecretKeyRef` env vars to vMCP Deployment for `addHeadersFromSecret`
928+
entries on `type: direct` endpoints; store env var names (not values) in
929+
backend ConfigMap
912930
4. Mount CA bundle ConfigMaps as volumes
913931
5. Implement post-exchange audience validation in token exchange strategy
914932
6. Extend vMCP audit middleware for `type: direct` (remote URL, auth outcome,

0 commit comments

Comments
 (0)