Skip to content

Support secret references for MCP server headers and env#431

Open
axon-agent[bot] wants to merge 4 commits intomainfrom
axon-task-313
Open

Support secret references for MCP server headers and env#431
axon-agent[bot] wants to merge 4 commits intomainfrom
axon-task-313

Conversation

@axon-agent
Copy link

@axon-agent axon-agent bot commented Feb 25, 2026

Summary

  • Adds headersFrom and envFrom fields to MCPServerSpec that reference Kubernetes Secrets for storing sensitive values (auth tokens, passwords) instead of inline plaintext
  • The controller resolves secret references in createJob before building the MCP servers JSON, merging secret values into inline headers/env maps with secret values taking precedence for overlapping keys
  • Follows the same pattern as existing credential secret resolution (GitHub App token, workspace secrets)
  • Uses a SecretValuesSource wrapper struct with a nested secretRef field, consistent with the Credentials.SecretRef pattern and extensible for future non-secret sources

Example usage:

mcpServers:
- name: github
  type: http
  url: https://api.githubcopilot.com/mcp/
  headersFrom:
    secretRef:
      name: mcp-github-headers
- name: local-db
  type: stdio
  command: npx
  args: ["-y", "@bytebase/dbhub"]
  envFrom:
    secretRef:
      name: mcp-db-env

Test plan

  • Unit tests for resolveMCPServerSecrets covering: headersFrom resolution, envFrom resolution, precedence of secret values over inline values, missing secret error handling, no-op when no secret refs
  • Unit tests for job builder verifying resolved headers/env appear in AXON_MCP_SERVERS JSON
  • Integration tests (envtest) covering: headersFrom resolution, envFrom resolution, missing secret causing Task failure with MCPSecretFailed event, secret value precedence over inline values
  • make verify passes
  • make test passes

Fixes #313

🤖 Generated with Claude Code

Add headersFrom and envFrom fields to MCPServerSpec that reference
Kubernetes Secrets. The controller resolves these secrets in createJob
before building the MCP servers JSON, merging secret values into
inline headers/env maps with secret values taking precedence for
overlapping keys.

Fixes #313

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 7 files

Copy link
Collaborator

@gjkim42 gjkim42 left a comment

Choose a reason for hiding this comment

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

/reset-worker

// Values from HeadersFrom take precedence over inline Headers for
// overlapping keys.
// +optional
HeadersFrom *SecretReference `json:"headersFrom,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it better to have secretFef field in HeadersFrom?

Wrap SecretReference in a SecretValuesSource struct so that
headersFrom and envFrom use a nested secretRef field. This
follows the same pattern as Credentials.SecretRef and makes
the API extensible for future non-secret sources.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@axon-agent
Copy link
Author

axon-agent bot commented Feb 25, 2026

🤖 Axon Agent @gjkim42

Addressed the review feedback in d5853ed:

Introduced a SecretValuesSource wrapper struct with a nested secretRef field, matching the Credentials.SecretRef pattern. The YAML now looks like:

headersFrom:
  secretRef:
    name: mcp-github-headers

This also makes the API extensible for future non-secret sources (e.g., configMapRef).

Copy link
Collaborator

@gjkim42 gjkim42 left a comment

Choose a reason for hiding this comment

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

Add integration or e2e tests for this.

/reset-worker

gjkim42 and others added 2 commits February 25, 2026 20:56
Implements comment-based workflow control from #417 to support autonomous
workflows on repositories where label permissions are unavailable.

- Adds triggerComment field to GitHubIssues spec: include issues only
  when a comment matches (e.g., /axon pick-up). Also acts as resume
  command when used with excludeComments.
- Adds excludeComments field ([]string): exclude issues with a comment
  matching any of these strings. Supports multiple exclusion patterns,
  consistent with excludeLabels.
- Comments scanned in reverse chronological order; most recent wins.
- Commands must appear on their own line to avoid false matches in prose.
- Labels remain the default; comment-based control is a fallback.

Files changed:
- api/v1alpha1/taskspawner_types.go: new comment fields on GitHubIssues
- api/v1alpha1/zz_generated.deepcopy.go: auto-generated
- cmd/axon-spawner/main.go: comment field passthrough to GitHubSource
- internal/source/github.go: passesCommentFilter, containsCommand,
  containsAnyCommand logic
- install-crd.yaml, internal/manifests/install-crd.yaml: CRD updates
- Test files with comprehensive unit and integration coverage

Closes #417

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds envtest-based integration tests covering headersFrom/envFrom
secret resolution in the Task controller, as requested in review.

Tests cover:
- headersFrom: secret headers merged into AXON_MCP_SERVERS JSON
- envFrom: secret env vars merged into AXON_MCP_SERVERS JSON
- Missing secret causes Task to fail with MCPSecretFailed event
- Secret values take precedence over inline values for overlapping keys

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Collaborator

@gjkim42 gjkim42 left a comment

Choose a reason for hiding this comment

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

rebase on origin/main. you should not have unwanted patches
/reset-worker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support secret references for MCP server headers and env

1 participant