Skip to content

fix(init): project client context connection env onto the DIR MCP entry - #1876

Merged
akijakya merged 1 commit into
mainfrom
fix/init-mcp-server-env
Jul 23, 2026
Merged

akijakya merged 1 commit into
mainfrom
fix/init-mcp-server-env

Conversation

@akijakya

@akijakya akijakya commented Jul 23, 2026 •

Copy link
Copy Markdown
Member

What

dirctl init now writes the client context's connection settings into the DIR MCP server entry's env, instead of leaving it empty.

Why

dirctl mcp serve reads its Directory connection settings only from DIRECTORY_CLIENT_* environment variables — it consults neither the client config file nor current_context. The installed entry shipped env: {}, so every spawned server ignored the context just configured during init and fell back to the 0.0.0.0:8888 default. Worse, with an empty auth mode the client attempts OIDC auto-detection, which fails outright on machines with multiple cached issuers — surfacing as agntcy-dir · ✘ failed in the host.

What's projected

From the resolved context (env overrides applied, validation skipped so a partial config still works):

  • Always: SERVER_ADDRESS and AUTH_MODE (empty mode defaults to insecure, matching the local daemon default).
  • When set: TLS cert/key/CA paths, TLS_SKIP_VERIFY, SPIFFE socket, OIDC issuer/client-id, JWT audience.
  • Never: AUTH_TOKEN and SPIFFE_TOKEN — the two secrets are excluded so a bearer token never lands in an agent config file.

Injection happens in the init flow only (via a new Artifacts.SetMCPEnv helper), so the generic published record and dirctl install <record> are unaffected.

Testing

  • Unit tests for SetMCPEnv (overlay onto existing entries; create the env map when absent).
  • dirctl init test asserts the written config carries both the address and auth-mode env keys.

@akijakya akijakya self-assigned this Jul 23, 2026
@akijakya
akijakya requested a review from a team as a code owner July 23, 2026 09:22
@github-actions github-actions Bot added the size/S Denotes a PR that changes 50-199 lines label Jul 23, 2026
@akijakya
akijakya force-pushed the fix/init-mcp-server-env branch from db5f07d to 2a7ded8 Compare July 23, 2026 09:22
@akijakya
akijakya force-pushed the fix/init-mcp-server-env branch from 2a7ded8 to 14883fd Compare July 23, 2026 09:36
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.95238% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cli/cmd/init/agents.go 75.8% 5 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

@akijakya
akijakya merged commit 2e33894 into main Jul 23, 2026
32 checks passed
@akijakya
akijakya deleted the fix/init-mcp-server-env branch July 23, 2026 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Denotes a PR that changes 50-199 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants