Skip to content

[Gap]: Document MCPExternalAuthConfig headerInjection/bearerToken for Kubernetes #1013

Closed

Description

@danbarr

What needs documentation?

MCPExternalAuthConfig supports two types for proxy-level static credential injection into backend requests — headerInjection (headerName + valueSecretRef, any custom header) and bearerToken (tokenSecretRef, specifically Authorization: Bearer) — referenced via externalAuthConfigRef on MCPServer and MCPRemoteProxy. Neither has Kubernetes documentation or a worked example.

Note this is distinct from, and narrower than, the well-documented common path for static credentials: spec.secrets env-var injection (run-mcp-k8s.mdx#run-a-server-with-secrets) and the HashiCorp Vault integration, which cover the case where the MCP server's own code reads the credential itself. headerInjection/bearerToken operate at the proxy layer instead — the same interception point as token exchange and AWS STS — so they matter for MCP servers that don't natively support reading credentials from the environment, or where centralizing the credential in a shareable MCPExternalAuthConfig (like MCPAuthzConfig's cross-resource sharing) is preferred over a per-server Secret reference.

The closest existing coverage:

  • guides-vmcp/authentication.mdx's "Static header injection" section documents headerInjection, but only for VirtualMCPServer.
  • guides-k8s/remote-mcp-proxy.mdx's "Inject custom headers" section documents a different, MCPRemoteProxy-specific headerForward.addHeadersFromSecret field with a similar outcome but a different mechanism.

Context and references

Surfaced while restructuring guides-k8s/auth-k8s.mdx (see the "Choose a backend authentication pattern" section, mapping concepts/backend-auth.mdx#choosing-the-right-backend-authentication-pattern's four patterns to K8s how-tos).

Use case

As a K8s operator, I want to inject a static API key or bearer token into backend requests at the proxy level (not via the MCP server's own environment), so I can centralize and rotate the credential independently of the server's deployment, and so it works even for MCP server images that don't support reading auth from the environment.

Additional context

Suggested home: a new section, likely alongside or cross-linked from remote-mcp-proxy.mdx's header-forwarding content, with a worked example verified against the live CRD schema.

Activity

  1. added
    documentation
    enhancement
    on Jul 6, 2026
  2. added
    needs-triage
    on Jul 6, 2026
  3. danbarr commented on Jul 21, 2026

    @danbarr
    CollaboratorAuthor

    Premise check against the toolhive source (verified at v0.40.1 and re-checked on current main): this issue overstates what works, and PR #1053 initially documented it as written, which is how the gap surfaced.

    • headerInjection is a silent no-op for both MCPServer and MCPRemoteProxy. Both reconcilers dispatch externalAuthConfigRef through AddExternalAuthConfigOptions, and the headerInjection case is an explicit placeholder (cmd/thv-operator/pkg/controllerutil/tokenexchange.go:386-401): no header injected, no error, no status condition. The only functional consumer of this type is VirtualMCPServer outgoing auth (cmd/thv-operator/controllers/virtualmcpserver_deployment.go:828, pkg/vmcp/auth/strategies/header_injection.go), which guides-vmcp/authentication.mdx already documents.
    • bearerToken works on MCPRemoteProxy only. It wires runner.WithRemoteAuth (tokenexchange.go:403-448), and remote auth is applied only when RemoteURL is set (pkg/runner/runner.go:430-434). MCPServer never sets one, so referencing a bearerToken config from an MCPServer validates and then does nothing.

    So the "works even for MCP server images that don't support reading auth from the environment" use case doesn't exist today; for MCPServer, env-var injection (spec.secrets / Vault) remains the only static-credential mechanism. Re-scoping this issue to documenting bearerToken for MCPRemoteProxy, alongside the headerForward content in remote-mcp-proxy.mdx.

    The silent acceptance also deserves an upstream toolhive issue: either implement these types for MCPServer/MCPRemoteProxy or reject/status-flag the unsupported reference instead of no-op'ing.

  4. self-assigned this
    on Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

documentationenhancementneeds-triage

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions