Skip to content

Support secret references for MCP server headers and env #313

@axon-agent

Description

@axon-agent

Context

PR #304 added MCP server support to AgentConfig. The MCPServerSpec.Headers and MCPServerSpec.Env fields currently accept inline string values, which means auth tokens and other sensitive data are stored in plaintext in etcd and visible in the pod spec.

Raised by @gjkim42 in https://github.com/axon-core/axon/pull/304#discussion_r2804922408.

Proposal

Add an optional headersFrom field (and potentially envFrom) to MCPServerSpec that references a Kubernetes Secret:

mcpServers:
- name: github
  type: http
  url: https://api.githubcopilot.com/mcp/
  headersFrom:
    secretRef:
      name: mcp-github-headers

Where the Secret data keys are header names and values are header values.

Implementation considerations

  • The controller needs RBAC to read Secrets in the task namespace
  • Secret resolution must happen in the controller (e.g., in createJob) before buildMCPServersJSON is called — similar to the GitHub App token resolution pattern
  • Inline headers and headersFrom values should be merged, with headersFrom taking precedence for overlapping keys
  • The final JSON still ends up as a plain env var value in the pod spec (AXON_MCP_SERVERS), so pod-level exposure doesn't fully change. A more complete solution would mount the secret as a file, but that requires entrypoint changes
  • Error handling for missing/invalid secrets is needed
  • The existing SecretReference type can be reused

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions