Skip to content

feat: connect a coding agent to the server's MCP endpoint from zitadel setup - #3549

Merged
fforootd merged 3 commits into
mainfrom
claude/mcp-skills-and-secrets
Dec 2, 2026
Merged

fforootd merged 3 commits into
mainfrom
claude/mcp-skills-and-secrets

Conversation

@fforootd

@fforootd fforootd commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Context

  • Answers ADR 092 open question 1 ("Does setup write the client's configuration?").

Related work found in a search of issues and pull requests, open and closed: #2315 (the zitadel mcp stdio prototype in the CLI) and #2451 (zitadel login for the CLI and MCP clients) are closed drafts; nothing open writes an MCP client's configuration. No overlap.

Summary

  • zitadel setup writes .mcp.json at the app's root, the file Claude Code and the Copilot agent in VS Code read. It names the server's MCP endpoint (<server>/api/v1/mcp) as the server zitadel.
  • The file is committed and holds no secret. Claude Code runs its headersHelper (node -p …) in the project's directory once the person trusts the folder; it reads the project secret from the git-ignored .zitadel/secret. VS Code runs no helper and fills headers from ${ZITADEL_PROJECT_SECRET:-} in the environment it was started in. The empty default keeps Claude Code from warning about a variable it does not need.
  • Setup adds its server beside the servers a .mcp.json already names. It leaves a file alone when it already names zitadel or is not a JSON object. It writes none for --server mock.
  • The endpoint's URL is built in one place (mcpEndpointOf), so a tool set or read-only path can be added there later.
  • The AGENTS.md guidance names the endpoint. A new docs guide, "Connect an AI agent", explains the file and shows Cursor and Codex by hand. The SDK pages and Agent setup link to it. SKILL.md and ADR 092 record the decision.

Validation

Run by the session that wrote the change, in its cloud container:

  • vitest run of the whole CLI with TERM=xterm-256color: every test passes but one, which fails only as root: auth-method sso enable when the schema cannot be written relies on chmod to stop a write. With the container's default TERM=linux, about 40 terminal-rendering tests also fail; they pass with a Unicode terminal. Both failures are environmental.
  • biome check src tests and the CLI typecheck: clean.
  • setup.spec.ts: 132 pass, including three new specs. .mcp.json is committed, holds no project secret, and is left alone when hand-written.
  • Unit tests cover the transform (create, add beside, leave alone, idempotent). One runs the helper command in a directory with a .zitadel/secret and checks the header it prints.
  • Real client: zitadel setup --server http://localhost:8080 --framework next against a local server built from this branch. Claude Code 2.1.334 started in the app, with the folder trusted and the server approved, reports zitadel … √ Connected with no environment variable set. The server log shows its requests authenticated (200).
  • After CI's first run failed on formatting and on the conformance fixtures, a second commit formats the three patcher tests and makes the conformance generator drop .mcp.json with the other files setup writes for people and agents, so fixtures do not carry it and do not drift.

Checked again when opening this draft: node scripts/check-pr-title.mjs --title "…" passes, and the branch is one commit on current main.

Release notes / changeset

  • Changeset: .changeset/setup-mcp-client-config.md (@zitadel/cli, minor). zitadel setup writes .mcp.json, which connects Claude Code and VS Code to the MCP endpoint without a secret in the file.

Notes

  • Decided here, for the owner to confirm: only .mcp.json is written, because one file covers Claude Code and VS Code. Cursor (.cursor/mcp.json, ${env:…} only) and Codex (.codex/config.toml, http_headers_helper or bearer_token_env_var) are shown in the guide and not written. Writing them is a small follow-up.
  • The connection carries the project secret, which stands for every scope, as the CLI in the same folder does. A narrower default (a read-only URL) becomes possible once the endpoint takes tool sets and read-only in its URL, which is in progress separately.
  • doctor --fix replays the edit, as it does for the guidance sections, so it restores a zitadel entry someone deleted.
  • eject leaves .mcp.json as it is.
  • Independent of the two other pieces from the same session: the skill on the endpoint, and the client-secret rotation.
  • Written in the session https://claude.ai/code/session_0137eGmSarR3gn9oz3Btwd8H; the draft was opened by the coordinating session below.

https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U


Generated by Claude Code

…l setup

setup writes a root .mcp.json, the file Claude Code and the Copilot agent
in VS Code read, naming the server's MCP endpoint as the server `zitadel`.
The file is committed and holds no secret: its headersHelper, which Claude
Code runs in the project's directory once the person trusts the folder,
reads the project secret from the git-ignored .zitadel/secret, and its
headers name ${ZITADEL_PROJECT_SECRET:-} for a client that fills it from
its environment.

setup adds its server beside the servers a .mcp.json already names and
leaves alone one that names `zitadel` or is no JSON object. The AGENTS.md
guidance names the endpoint, a docs guide explains the file and how to
connect other clients, and ADR 092 records the answer to its open
question 1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmSarR3gn9oz3Btwd8H
@vercel

vercel Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cloud Ready Ready Preview Dec 2, 2026 2:42pm UTC

Request Review

@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

🦋 Changeset detected

Latest commit: 8b6a2c6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 27 packages
Name Type
@zitadel/cli Minor
@zitadel/testing Minor
@zitadel/server Minor
@zitadel/server-darwin-arm64 Minor
@zitadel/server-darwin-x64 Minor
@zitadel/server-linux-arm64 Minor
@zitadel/server-linux-x64 Minor
@zitadel/server-win32-x64 Minor
@zitadel/api Minor
@zitadel/components Minor
@zitadel/config Minor
@zitadel/sdk-angular Minor
@zitadel/sdk-core Minor
@zitadel/sdk-next Minor
@zitadel/sdk-nuxt Minor
@zitadel/sdk-qwik Minor
@zitadel/sdk-qwik-router Minor
@zitadel/sdk-react Minor
@zitadel/sdk-solid Minor
@zitadel/sdk-solid-start Minor
@zitadel/sdk-svelte Minor
@zitadel/sdk-sveltekit Minor
@zitadel/sdk-tanstack-start Minor
@zitadel/sdk-vue Minor
@zitadel/cloud Patch
@zitadel/client-sdk-contract Patch
@zitadel/server-sdk-contract Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

The fixture generator drops what setup writes that the app never reads.
.mcp.json is an agent's configuration, and names the server setup ran
against rather than the one the lane serves, so it is dropped as
zitadel.json, AGENTS.md and README.md are, and the fixtures do not drift
with the port they were generated on.

Also formats the three patcher tests the .mcp.json edit touched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmSarR3gn9oz3Btwd8H
@fforootd
fforootd marked this pull request as ready for review December 2, 2026 14:08
Copilot AI balanced review requested due to automatic review settings December 2, 2026 14:08
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-12-02T14:19:36.047222Z b33dbd0 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The patch does not configure VS Code’s Copilot agent, and doctor --fix fails to restore a deleted .mcp.json file or zitadel entry.

2 open issues
What changed in this PR

Adds MCP client configuration to zitadel setup, connecting coding agents to the server’s existing API tools.

Changes:

  • Generates .mcp.json with credential references while preserving existing server entries.
  • Adds configuration tests and excludes MCP configuration from conformance fixtures.
  • Documents agent connections and records the setup decision.
File Description
docs/​adrs/​092-mcp-server.md Records the client-configuration decision.
conformance/​suite/​bin/​conformance-fixture.mjs Excludes .mcp.json from fixtures.
apps/​docs/​content/​docs/​sdks/​vue.mdx Links agent connection guidance.
apps/​docs/​content/​docs/​sdks/​tanstack-start.mdx Links agent connection guidance.
apps/​docs/​content/​docs/​sdks/​sveltekit.mdx Links agent connection guidance.
apps/​docs/​content/​docs/​sdks/​svelte.mdx Links agent connection guidance.
apps/​docs/​content/​docs/​sdks/​solid.mdx Links agent connection guidance.
apps/​docs/​content/​docs/​sdks/​solid-start.mdx Links agent connection guidance.
apps/​docs/​content/​docs/​sdks/​react.mdx Links agent connection guidance.
apps/​docs/​content/​docs/​sdks/​qwik.mdx Links agent connection guidance.
apps/​docs/​content/​docs/​sdks/​qwik-router.mdx Links agent connection guidance.
apps/​docs/​content/​docs/​sdks/​nuxt.mdx Links agent connection guidance.
apps/​docs/​content/​docs/​sdks/​next.mdx Links agent connection guidance.
apps/​docs/​content/​docs/​sdks/​angular.mdx Links agent connection guidance.
apps/​docs/​content/​docs/​guides/​meta.json Adds the guide to navigation.
apps/​docs/​content/​docs/​guides/​connect-an-agent.mdx Explains client configuration and permissions.
apps/​docs/​content/​docs/​get-started/​agents.mdx Introduces MCP connections.
apps/​cli/​tests/​unit/​lib/​orca/​patchers/​rule/​tanstack-start/​index.test.ts Adjusts expected configuration edits.
apps/​cli/​tests/​unit/​lib/​orca/​patchers/​rule/​sveltekit/​index.test.ts Adjusts expected configuration edits.
apps/​cli/​tests/​unit/​lib/​orca/​patchers/​rule/​qwik-router/​index.test.ts Adjusts expected configuration edits.
apps/​cli/​tests/​unit/​lib/​orca/​patchers/​rule/​mcp-client.test.ts Tests configuration merging and credential helper.
apps/​cli/​tests/​unit/​lib/​orca/​patchers/​rule/​guidance.test.ts Tests generated MCP guidance.
apps/​cli/​tests/​unit/​lib/​json.test.ts Tests nested JSON edits.
apps/​cli/​tests/​integration/​setup.spec.ts Tests setup’s MCP file handling.
apps/​cli/​tests/​helpers/​project.ts Adds MCP configuration test helpers.
apps/​cli/​src/​lib/​orca/​patchers/​rule/​mcp-client.ts Generates and merges MCP configuration.
apps/​cli/​src/​lib/​orca/​patchers/​rule/​guidance.ts Adds endpoint guidance for agents.
apps/​cli/​src/​lib/​orca/​patchers/​rule/​base.ts Includes MCP configuration in setup plans.
apps/​cli/​src/​lib/​json.ts Supports targeted nested JSON edits.
apps/​cli/​skills/​zitadel-cli/​SKILL.md Documents setup’s MCP behavior.
.changeset/​setup-mcp-client-config.md Adds CLI minor-release notes.

Review effort: Balanced

import type { FileOp } from "./file-writer/types";

/** The file setup writes, at the project's root. */
export const MCP_CONFIG_FILE = ".mcp.json";
return [
{
kind: "edit",
path: MCP_CONFIG_FILE,
@fforootd
fforootd added this pull request to the merge queue Dec 2, 2026
Merged via the queue into main with commit dbc1f76 Dec 2, 2026
17 checks passed
@fforootd
fforootd deleted the claude/mcp-skills-and-secrets branch December 2, 2026 14:53
@github-project-automation github-project-automation Bot moved this from Inbox to Done in Engineering Kanban Dec 2, 2026

This branch was successfully deployed

1 active deployment
Preview — 8b6a2c6e Deployed Dec 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants