Skip to content

feat: Add MCP endpoint to serve API operations as tools - #3480

Merged
fforootd merged 30 commits into
mainfrom
claude/festive-hamilton-y0f0dx
Dec 1, 2026
Merged

fforootd merged 30 commits into
mainfrom
claude/festive-hamilton-y0f0dx

Conversation

@fforootd

@fforootd fforootd commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Context

Summary

The Go server serves its own API to an AI agent as Model Context Protocol tools at /api/v1/mcp. ADR 092 (Proposed) records the design and what follows.

  • One tool per API operation. The tools are read from the OpenAPI document the server already embeds, so a new operation becomes a tool without more code.
  • A tool takes its words from the spec. Its name is the operationId, its title the summary, and its description the first sentence of the operation's description. Eight summaries that still named an earlier operation name are corrected (deleteGrant was titled "Revoke a grant"), and a test holds that a tool's title opens with the verb of its name.
  • A tool call is the operation's own HTTP request, served in-process with the caller's credential. Authorization, validation and the audit record are the API's, so the endpoint gives a caller nothing the API does not.
  • The credential is a project secret, sent as the bearer. A request without an accepted one gets 401 before the protocol library reads it.
  • On by default. mcp.enabled (NEXTGEN_MCP_ENABLED) turns the endpoint off.
  • Scopes decide which tools a client is shown. Every operation names the scopes it needs in the OpenAPI document. The endpoint shows a client a tool only when its credential carries every scope of the tool's operation, by the rule the API checks a scope with. No setting of the server adds or hides a tool, and authorization stays the API's. The API itself does not enforce an operation's scopes yet; nothing is exposed while the only credential it takes carries every scope, and ADR 092's open question 14 records what must change before a narrower one reaches it.
  • A project secret covers every scope (the API reads its project.write as all of them), so a client that holds one is shown all the tools, writes among them, as the CLI with that secret can call every operation. An agent that should only read needs a credential that only reads, which the management API does not take yet (ADR 092, open question 13).
  • Destructive calls ask first. A tool that deletes, revokes, rolls back, deploys or replaces a user's password asks the person at the client to confirm, through the protocol's multi round-trip requests (revision 2026-07-28). A client that cannot ask is refused, and the request is not sent. createDeployment is now marked destructive in the spec, as rollbackDeployment was, since both replace what a project serves. zitadel api createDeployment asks first for the same reason; zitadel deploy, deployment create and preview already asked on their own terms. setUserPassword is marked destructive too: the password it replaces cannot be put back, and whoever sets one can sign in as that user.
  • No credentials in an agent's context. An operation whose response carries a secret is never a tool: a client secret, a session token, an invitation's link, which gives its role to whoever opens it, or a claim's link, which gives the project to the team of whoever opens it. Neither is an operation of the app plane or one that takes a session cookie.
  • A hint claims only what the spec says. A read is marked read-only. A write is marked destructive only where the spec marks it, and no write claims that it only adds, so a client falls back to the protocol's cautious defaults.
  • Stateless. No sessions and no server-sent events: each request is answered with one JSON response.
  • The tool list is the caller's to keep. Its result says cacheScope: private and a ttlMs of five minutes, since the credential's scopes decide the list. The protocol library's default would have called it public.
  • A tool call keeps the request ID of the MCP request that carried it, so the operation's log line and its request.api event are found by the X-Request-Id the client was answered with.
  • The tool list is built on the first authenticated request (about 50 ms), not at start, so a server no agent connects to pays nothing.

Three new markers in the OpenAPI source make this readable from the spec: x-zitadel-read-only (a POST that changes nothing), x-zitadel-plane: app and x-zitadel-returns-secret. @zitadel/api's generated operation table carries them as readOnly, plane and returnsSecret.

A credential that carries every scope is shown 76 tools (about 127 KB as a client lists them; a test holds the list under 130 KB, so the next few operations will trip it and ask for the decision ADR 092 leaves open). A credential with fewer scopes is shown fewer. One tool may weigh 16 KB at most: buildRelease would weigh 35 KB, because its input repeats the schema of every kind of config, so it is not a tool, and a test names each operation left out for that reason.

Validation

Run in apps/api unless noted:

  • go vet ./...
  • go test ./internal/mcp/ ./cmd/server/ ./cmd/cloud-launcher/ ./internal/api/ -count=1
  • go test -tags sqlite_integration ./internal/api/integration_test/ -count=1 -timeout 20m
  • node scripts/go-lint.mjs (repo root)
  • turbo run check-generate openapi --filter=@zitadel/server and node scripts/check-go-work.mjs (repo root)
  • By hand against the built server, at the current path: /api/v1/mcp answers 401 to a request without a credential, and /mcp at the root answers 404.
  • By hand before the endpoint moved under the prefix: 401 with a Bearer challenge, 404 with NEXTGEN_MCP_ENABLED=false, and with a real project secret getProject, queryTeams, createTeam, and deleteUser refused for a client that cannot confirm.

Not run: the Postgres and Spanner integration lanes, and a client that is not the Go SDK's own. The TypeScript SDK's @modelcontextprotocol/sdk 1.32.2 speaks no protocol revision after 2025-11-25, so a client built on it can list and call tools and is refused on the destructive ones; @modelcontextprotocol/client 2.4.0 speaks 2026-07-28. That is read from the packages, not from a connection.

After a review of the PR, one more commit (266030d), with go vet ./..., go test ./internal/mcp/ ./cmd/... -count=1 and node scripts/go-lint.mjs:

  • a tool's input schema keeps properties whose names start with x- (a user schema's x-auth-methods, x-identifier, x-display) or are called example; the filter for vendor extensions had dropped them, and publishSchema required a property it no longer described;
  • the question before a destructive call shows the arguments as given (JSON in ASCII, cut at 600 bytes), so deploying one release or another no longer asks the same thing;
  • a yes counts for five minutes from its question, not for ever.

After the reviews by people, one more commit (aff8f67) and a line in ADR 092's non-goals:

  • createProjectClaim is no tool any more (x-zitadel-returns-secret), which decides ADR 092's open question 9;
  • setUserPassword asks first (x-zitadel-destructive), on the endpoint and on zitadel api setUserPassword;
  • a question shows a number, and binds it, as it was written (an integer past 2^53 was shown rounded);
  • a tool's schema drops OpenAPI's discriminator, whose mapping named components the schema does not hold, and a test holds that no tool's schema names one;
  • a tool call's request keeps the request ID of the MCP request;
  • the bearer challenge reads the header as the protocol library does, so Bearer a b is challenged too;
  • the tool list is marked private to its caller.

Then main was merged in, because CI tests the merge: it had gained createTeamMembership and deleteTeamMembership, titled "Add a user to a team" and "Remove a member from a team", and the test that holds a tool's title to the verb of its name failed on both. Their summaries are now "Create a team membership" and "Delete a team membership" (f8429a8); their descriptions are unchanged.

Run for it: in apps/api, go vet ./..., go test ./... -count=1 and go test -tags sqlite_integration ./internal/api/integration_test/ ./internal/api/integration_test/helpers/ -count=1; at the repo root, turbo run lint --filter=@zitadel/server (which includes check-generate), pnpm run check-openapi-rules, node scripts/check-changesets-status.mjs, and in apps/cli the unit tests of the api command and the backend client.

Release notes / changeset

  • Changeset: .changeset/mcp-endpoint.md — the server serves its API as MCP tools at /api/v1/mcp (experimental) (@zitadel/server)
  • Changeset: .changeset/openapi-operation-markers.md — the OpenAPI document and the generated operation table mark read-only, app-plane and secret-returning operations (@zitadel/server, @zitadel/api)
  • Changeset: .changeset/deployment-asks-first.md — createDeployment and setUserPassword are marked destructive, so the MCP endpoint and zitadel api ask first (@zitadel/server, @zitadel/api, @zitadel/cli)

Notes

  • ADR number. This PR takes 092: main took 091 for release pinning on 2026-12-01, and the record was renumbered. Open PRs docs: propose project webhooks #2985 and docs: add an ADR on authentication requirements #3369 claimed 091 too.
  • Path. The endpoint is under the API's prefix because its tools are the v1 contract's operations (ADR 077 §3). The branch first served it at /mcp; ADR 092 lists that as a rejected alternative.
  • Cloud. vercel.json already sends /api/ to the server and mcp.enabled defaults to on, so the hosted cloud serves the endpoint once this merges, with no routing change. The server reads NEXTGEN_MCP_ENABLED=false to hold it back. A test pins that /mcp at the root stays the website's.
  • A password an agent sets passes through the model, as an argument, and the question shows it to the person at the client. The CLI has no command for it either, short of api.
  • An event does not say that its request came through the endpoint (ADR 092, open question 5). The request ID is what ties the two together.
  • New dependency. github.com/modelcontextprotocol/go-sdk v1.9.0, the official Go SDK.
  • Same-machine reverse proxy. The SDK's loopback host check is turned off, because it refuses every request a proxy on the same machine forwards. The endpoint takes no ambient credential, only a bearer, so DNS rebinding gains nothing; a test covers it.
  • Follow-ups in ADR 092, not in this PR: a person's token on the endpoint (needs OAuth pieces the server does not have yet), customers' MCP servers that Zitadel protects, and Agent Skills over MCP.
  • History. The branch first added a zitadel mcp command to the CLI and then reverted it. The only CLI change left in the diff is six lines in apps/cli/src/lib/backend/services/operation.ts, which give the CLI's Operation type the three new marker fields.

https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U


Generated by Claude Code

…ver follows

ADR 091, proposed. "MCP in Zitadel" is a local stdio server in the CLI,
/mcp on the platform project's issuer, and the MCP servers customers
build with Zitadel as their authorization server, built in order of
dependency.

It records that a tool is one operation generated from the operation
table, that the spec marks which operations only read, belong to
applications or return a credential, that an agent reads by default and
writes only in development, and that a destructive call needs the
person's confirmation for that call. The local server is experimental
and second to the CLI for an agent that has a shell; whether it ships
beyond that is an open question.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
…s in the spec

Three facts a client had to guess from a method or a name are now said
on the operation, beside x-zitadel-cli and x-zitadel-destructive:

- x-zitadel-read-only: a POST that changes nothing (the queries, the
  search, a policy evaluation, the invitation lookup).
- x-zitadel-plane: app: an operation an application's backend calls
  while a user signs in (auth attempts, session creation and exchange,
  passkey registration).
- x-zitadel-returns-secret: a response that carries a secret shown once
  or a token that signs a caller in.

The operation table carries them as readOnly, plane and returnsSecret,
and the CLI's Operation reads them. Only the bundled OpenAPI document
changes among the generated files.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
A port of the #2315 prototype to the current CLI, with the rules of
ADR 091. Experimental, and marked so in its help and in SKILL.md.

zitadel mcp is a stdio MCP server an MCP client starts. It serves one
tool per operation an operator calls, named by its operationId and typed
by the generated schemas, with the server and project secret every
project command resolves.

- Only read-only operations are tools unless --allow-writes, which is
  refused outside the development environment unless --dry-run is given.
- A tool that deletes, revokes or rolls back asks the person at the
  client first, and sends nothing when they decline, when the client
  cannot ask, or when a confirmation arrives for a call nothing asked
  about.
- An application-plane operation and one that returns a credential are
  never tools.
- stdout carries the protocol alone: --json and a run at a terminal are
  refused before the first byte.

The protocol library loads only when a session is served, so no other
command pays for it.

Not in this change: an integration spec for the command, a docs page on
connecting a client, and a telemetry dimension.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
This reverts commit efa4e84. The server already runs on a developer's
machine, so an MCP endpoint in the server is local too, and one
implementation then serves a local server, a self-hosted one and the
cloud with the rules enforced by the server. The CLI command only
mirrored API operations, which an agent with a shell already calls with
the api command.

The spec markers and the operation table fields stay.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
The Go server can mount a Model Context Protocol endpoint at /mcp
(ADR 091). Experimental and off by default: mcp.enabled turns it on.

- A tool is one operation of the API, read from the embedded OpenAPI
  document when the server starts. Its input schema is the spec's, with
  the component schemas it refers to in its own $defs.
- A tool call is the operation's own request, served in-process by the
  API's handler behind the whole middleware chain with the caller's
  bearer, so it is authenticated, authorized, validated, limited and
  logged as the same request over HTTP is.
- The credential is a project secret as the API takes it. A request
  without one is challenged with 401; a server that cannot check one
  answers 500, never 401.
- Only read-only operations are tools unless mcp.allow_writes is set.
  An application-plane operation and one that returns a credential are
  never tools.
- A tool that deletes, revokes or rolls back asks the person at the
  client first (multi round-trip requests), bound to that exact call by
  a state keyed with the credential. A client on a protocol revision
  before 2026-07-28 cannot be asked and is refused.
- Streamable HTTP without sessions, answering JSON. The library's
  loopback host check is off, since a reverse proxy on the same machine
  forwards under the public host name and the endpoint takes no ambient
  credential.

ADR 091 is rewritten around the endpoint, with the CLI stdio server as
a rejected alternative. Adds github.com/modelcontextprotocol/go-sdk
v1.9.0.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
… use

mcp.enabled now defaults to true; mcp.allow_writes stays false.

The endpoint opens nothing new: a caller needs the credential the API
takes, and reading only it offers less than the API does. A switch that
defaults to off would only keep agents out of servers whose operators
never heard of it.

So that a server no agent connects to pays nothing for it, the tools
are built on the first request that carries a credential the server
accepts, not at start: reading the embedded document and its schemas
takes about 50 ms. A request the server refuses never triggers the
build, and a document that cannot become tools fails this endpoint
with 500 while the API serves on.

Also tests that an id holding a slash stays inside its path segment,
against the fake API and over the real one.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
- The endpoint is on by default because it opens nothing, and costs a
  server nothing until it is used; off by default is a rejected
  alternative.
- Agent Skills through MCP's Skills extension
  (io.modelcontextprotocol/skills, SEP-2640) are wanted on the same
  endpoint: section 10, a step of the sequence, and an open question on
  which skills a server serves. Not built; the Go SDK at v1.9.0 does not
  carry the extension.

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

vercel Bot commented Nov 30, 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 1, 2026 6:03pm UTC

Request Review

@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

🦋 Changeset detected

Latest commit: f8429a8

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

This PR includes changesets to release 27 packages
Name Type
@zitadel/server Minor
@zitadel/api Minor
@zitadel/cli 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-react Minor
@zitadel/sdk-solid Minor
@zitadel/sdk-svelte Minor
@zitadel/sdk-tanstack-start Minor
@zitadel/sdk-vue Minor
@zitadel/testing Minor
@zitadel/cloud Patch
@zitadel/client-sdk-contract Patch
@zitadel/sdk-qwik-router Minor
@zitadel/sdk-solid-start Minor
@zitadel/sdk-sveltekit Minor
@zitadel/server-sdk-contract Patch
@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

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

…ts the spec backs

createInvitation returns a link that gives its role to whoever opens it, and
the link appears only in that response. It is now marked
x-zitadel-returns-secret, so the MCP endpoint no longer offers it and the link
cannot enter a model's context.

Every write that was not marked destructive carried destructiveHint false,
which the protocol defines as "only additive updates". An update, a password
change and a variable removal are not that. Every tool also carried
openWorldHint false. A write now carries a destructive hint only where the
spec marks it, and no open-world hint, so a client reads the protocol's
defaults. A read stays marked read-only and closed.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
…and four open questions in ADR 091

Reading by default narrows the tools, not the project secret the client
holds. The Skills extension can be built on the Go SDK's custom methods now.
The protocol deprecated dynamic client registration and has an MCP server
pass no token on, which asks whether /mcp and the management API are one
protected resource. Open questions added: createProjectClaim as a tool, the
audience, tool names, and a marker for writes that only add.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
The pieces a person's token on /mcp needs were built once in the closed
prototype #2451, are read against the epic in #2860, and public clients are
being built again in #3409.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
…place of a server switch

mcp.allow_writes is gone. One server holds many projects, so a switch on the
server was the wrong size, and it hid tools from a client that still held a
credential that writes.

Every operation already names the scopes it needs in the OpenAPI document, and
the API checks a credential against them. The endpoint now reads those scopes
and shows a client a tool only when its credential carries every scope of the
tool's operation, by the API's own rule (the security handler hands the
endpoint the credential with that rule). The list is narrowed per request;
authorization stays the API's, which refuses a call to a tool a client was not
shown as it refuses that request from anywhere.

A project secret carries every scope, so a client that holds one is now shown
all 76 tools, writes among them. A destructive call still asks the person at
the client first. The integration test creates a team through a tool and sees a
deactivation left unsent when nobody can be asked.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
Section 5 is rewritten: the scopes each operation names decide the list, a
project secret carries them all today, and who may write is decided where an
agent is connected. The server switch and a per-project setting join the
rejected alternatives, and a credential that only reads is an open question.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
The earlier wording said the API checks a credential against the scopes an
operation names. It does not: it authorizes by the credential's ceiling and
the caller's grants, and checks a scope only on an expand. ADR 091, the
configuration guide and the code comments now say so, and the ADR records as
an open question where the check belongs and which scopes in the spec are off.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
A tool's description was its summary with the method and path, such as
"Update a team: PATCH /teams/{team_id}.". A model reads the description and
not the title, and the summary only names the operation. The description is
now the first sentence of the operation's description, which the spec writes
to stand alone: "Renames an active team. API: PATCH /teams/{team_id}.". The
question a destructive call asks the person carries the same sentence, so it
says what will happen and not only the operation's name.

The seven query tools take their page token in the body and had no paging
hint; they now carry one that says so.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
A summary is an MCP tool's title, an API reference page's title and the
generated clients' doc comment. Eight still named an operation as it was
called before the renames of #3007, so a tool named deleteGrant was titled
"Revoke a grant" and one named listVariables "Get a project's variables".
They now open with the verb of their operationId, and a test in the MCP
package holds that for every tool. search is "Search resources": it searches
the resources of projects, not the projects.

getUserPasswordState declared its user_id inline and without a description;
it now refers to the shared parameter, as setUserPassword on the same path
does.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
A tool takes its name, title and description from the spec. The API checks a
scope for an expand and for the kinds in a release bundle, and nowhere else.
The open questions now say which scope and name oddities are deliberate, which
break a written rule, and add buildRelease's weight and createDeployment's
missing question.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
…too heavy

Every session carries the whole tool list in the agent's context. buildRelease
was 35,000 bytes of it, more than a fifth, because its input repeats the
schema of every kind of config. It also takes the files of .zitadel/ as
written on disk, which an agent with a shell sends with the CLI.

One tool may now weigh 16,000 bytes at most. An operation whose tool would
weigh more stays an operation of the API and is not a tool, and a test names
each one, so the next to grow past the budget is dropped by a decision. The
list is 75 tools and 124,000 bytes, held under 130,000.

The confirmation texts no longer list delete, revoke and roll back, since a
deployment asks as well.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
Both replace what a project serves. A rollback asked before it was sent and a
deployment did not. The MCP endpoint now asks the person at the client before
a deployment, @zitadel/api lists it among destructiveOperations, and
`zitadel api createDeployment` asks first, so without a terminal it needs
--force. `zitadel deploy`, `deployment create` and `preview` are unchanged:
they already ask on their own terms.

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

chatgpt-codex-connector Bot commented Dec 1, 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-01T06:44:12.360705Z 410bc8b 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.

Main took 091 for release pinning.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U

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

Confirmation state can be replayed to execute later destructive invocations without fresh consent, violating the per-call confirmation guarantee.

3 open issues
What changed in this PR

Adds an experimental MCP endpoint at /api/v1/mcp, exposing eligible management API operations as tools through the existing API authorization and audit paths. This establishes project-secret access; personal OAuth access and customer MCP authorization remain follow-ups.

Changes:

  • Adds a default-enabled, stateless endpoint with scope-filtered tool discovery and destructive-call confirmation.
  • Introduces OpenAPI operation markers and propagates them into API metadata and CLI types.
  • Adds endpoint tests, configuration guidance, an architecture proposal, and release notes.
File Description
packages/​go/​api/​oas_parameters_gen.go Regenerates user-ID parameter documentation.
packages/​api/​scripts/​operations.ts Generates the three new operation markers.
go.work.sum Records workspace dependency checksums.
docs/​quick-start/​configuration.md Documents MCP configuration and client connection.
docs/​operations/​nextgen.example.yaml Adds the default-enabled MCP setting.
docs/​adrs/​README.md Indexes the MCP architecture proposal.
docs/​adrs/​091-mcp-server.md Defines MCP behavior, constraints, and follow-ups.
apps/​docs/​tests/​playground.browser.spec.ts Updates the grant operation title expectation.
apps/​cli/​src/​lib/​backend/​services/​operation.ts Exposes new operation metadata fields.
apps/​cli/​skills/​zitadel-cli/​SKILL.md Documents deployment confirmation for API calls.
apps/​api/​internal/​mcp/​handler.go Implements transport, authentication, calls, and confirmation.
apps/​api/​internal/​mcp/​handler_test.go Tests endpoint behavior and confirmation handling.
apps/​api/​internal/​mcp/​catalog.go Builds tool metadata and schemas from OpenAPI.
apps/​api/​internal/​mcp/​catalog_test.go Tests tool eligibility, schemas, and size budgets.
apps/​api/​internal/​api/​security.go Exposes bearer credential details for MCP.
apps/​api/​internal/​api/​integration_test/​mcp_test.go Exercises MCP against the management API.
apps/​api/​internal/​api/​generated/​oas_router_gen.go Regenerates operation summaries.
apps/​api/​internal/​api/​generated/​oas_parameters_gen.go Regenerates user-ID parameter documentation.
apps/​api/​internal/​api/​generated/​oas_handlers_gen.go Regenerates handler operation summaries.
apps/​api/​internal/​api/​authz.go Shares existing scope-matching logic.
apps/​api/​go.sum Records MCP dependency checksums.
apps/​api/​go.mod Adds the Go MCP SDK and dependencies.
apps/​api/​cmd/​server/​server.go Configures and mounts the MCP endpoint.
apps/​api/​cmd/​server/​server_test.go Tests MCP configuration defaults and overrides.
apps/​api/​cmd/​server/​mux_test.go Tests endpoint mounting and path isolation.
apps/​api/​cmd/​server/​config.go Defines MCP server configuration.
apps/​api/​cmd/​cloud-launcher/​main_test.go Checks cloud routing for MCP paths.
apps/​api/​api/​openapi/​endpoints/​variables/​methods.yaml Aligns variable operation summaries with names.
apps/​api/​api/​openapi/​endpoints/​users/​query/​methods.yaml Marks user queries read-only.
apps/​api/​api/​openapi/​endpoints/​users/​by_id/​password/​methods.yaml Reuses the documented user-ID parameter.
apps/​api/​api/​openapi/​endpoints/​users/​by_id/​passkeys/​registrations/​methods.yaml Marks passkey registration as app-plane.
apps/​api/​api/​openapi/​endpoints/​users/​by_id/​passkeys/​registrations/​by_id/​methods.yaml Marks registration completion as app-plane.
apps/​api/​api/​openapi/​endpoints/​teams/​query/​methods.yaml Marks team queries read-only.
apps/​api/​api/​openapi/​endpoints/​sessions/​query/​methods.yaml Marks session queries read-only.
apps/​api/​api/​openapi/​endpoints/​sessions/​methods.yaml Marks session creation app-plane and secret-returning.
apps/​api/​api/​openapi/​endpoints/​sessions/​exchange/​methods.yaml Marks session exchange app-plane and secret-returning.
apps/​api/​api/​openapi/​endpoints/​search/​methods.yaml Marks search read-only and corrects its summary.
apps/​api/​api/​openapi/​endpoints/​projects/​query/​methods.yaml Marks project queries read-only.
apps/​api/​api/​openapi/​endpoints/​projects/​methods.yaml Marks project creation secret-returning.
apps/​api/​api/​openapi/​endpoints/​projects/​by_id/​claim/​init/​methods.yaml Aligns the claim operation summary with its name.
apps/​api/​api/​openapi/​endpoints/​policies/​evaluate/​methods.yaml Marks policy evaluation read-only.
apps/​api/​api/​openapi/​endpoints/​invitations/​methods.yaml Marks invitation creation secret-returning.
apps/​api/​api/​openapi/​endpoints/​invitations/​lookup/​methods.yaml Marks invitation lookup read-only.
apps/​api/​api/​openapi/​endpoints/​idps/​query/​methods.yaml Marks identity-provider queries read-only.
apps/​api/​api/​openapi/​endpoints/​idps/​methods.yaml Aligns the publish operation summary.
apps/​api/​api/​openapi/​endpoints/​grants/​query/​methods.yaml Marks grant queries read-only.
apps/​api/​api/​openapi/​endpoints/​grants/​by_id/​methods.yaml Aligns the delete operation summary.
apps/​api/​api/​openapi/​endpoints/​flows/​submit/​methods.yaml Marks flow submission secret-returning.
apps/​api/​api/​openapi/​endpoints/​flows/​session/​methods.yaml Marks flow-step reads secret-returning.
apps/​api/​api/​openapi/​endpoints/​flows/​methods.yaml Marks flow creation secret-returning.
apps/​api/​api/​openapi/​endpoints/​deployments/​methods.yaml Marks deployment creation destructive.
apps/​api/​api/​openapi/​endpoints/​deployments/​by_id/​variables/​methods.yaml Aligns the variable-listing summary.
apps/​api/​api/​openapi/​endpoints/​auth_attempts/​methods.yaml Marks authentication-attempt creation app-plane.
apps/​api/​api/​openapi/​endpoints/​auth_attempts/​by_id/​methods.yaml Marks authentication-attempt reads app-plane.
apps/​api/​api/​openapi/​endpoints/​auth_attempts/​by_id/​handoff/​methods.yaml Marks handoffs app-plane and secret-returning.
apps/​api/​api/​openapi/​endpoints/​auth_attempts/​by_id/​challenges/​methods.yaml Marks challenge creation app-plane.
apps/​api/​api/​openapi/​endpoints/​auth_attempts/​by_id/​challenges/​by_id/​methods.yaml Marks challenge verification app-plane.
apps/​api/​api/​openapi/​endpoints/​applications/​query/​methods.yaml Marks application queries read-only.
apps/​api/​api/​openapi/​endpoints/​applications/​methods.yaml Marks publishing secret-returning and aligns its summary.
apps/​api/​api/​openapi/​bundled/​openapi.json Regenerates the bundled OpenAPI contract.
apps/​api/​api/​openapi/​AGENTS.md Documents operation marker conventions.
.changeset/​openapi-operation-markers.md Announces operation metadata and summary updates.
.changeset/​mcp-endpoint.md Announces the experimental MCP endpoint.
.changeset/​deployment-asks-first.md Announces deployment confirmation behavior.

Review effort: Balanced

Comment thread apps/api/internal/mcp/handler.go Outdated
Comment on lines +540 to +543
state := confirmationState(outer.Header.Get("Authorization"), inner, req.Params.Arguments)
answer, answered := req.Params.InputResponses[confirmation]
if answered && hmac.Equal([]byte(req.Params.RequestState), []byte(state)) {
if result, ok := answer.(*sdk.ElicitResult); ok && result.Action == "accept" && result.Content[confirmation] == true {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Taken in part, in 266030d. The state now carries the time the question was asked, and a yes counts for five minutes: the same call sent later, such as a rollback after another deployment, is asked about again. TestConfirmationStandsForItsCallAndItsTime covers it.

Not taken: rejecting a second use within those five minutes. That needs storage every instance of the server shares, and the endpoint is stateless by design (ADR 092 §5), so the state confirms the same call again until it expires. The ADR now says so.


Generated by Claude Code

Comment on lines +329 to +330
if droppedKeyword(keyword) {
continue
Comment thread apps/api/internal/mcp/handler.go Outdated
InputRequests: sdk.InputRequestMap{
confirmation: &sdk.ElicitParams{
Mode: "form",
Message: fmt.Sprintf("Call %s (%s %s) on %s? %s", op.id, op.method, inner.URL.Path, inner.Host, op.does()),
…estructive call with its arguments and for five minutes

Three findings of the review on the MCP endpoint:

- A tool's input schema lost every property whose name starts with `x-`
  (`x-auth-methods`, `x-identifier`, `x-display` of a user schema) or is
  called `example`, because the filter for vendor extensions and examples
  also ran over the names in `properties`. `publishSchema` then required a
  property it no longer described. Names in maps of named schemas are kept,
  and `enum`, `const` and `default` are copied as the data they are.
- The question before a destructive call showed the path only, so deploying
  one release or another, to one project or another, asked the same thing.
  It now shows the arguments as given, as JSON in ASCII and cut at 600
  bytes, and the path percent-encoded.
- A yes counted for the same call for ever. The confirmation's state now
  says when the question was asked, and a yes counts for five minutes: the
  same call sent later is asked about again. Single use would need storage
  every instance shares, which the endpoint does not have.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U

@wim07101993 wim07101993 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looks good, some small comments

@@ -1,6 +1,6 @@
post:
operationId: createProjectClaim

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This one needs x-zitadel-returns-secret: true. The response's claim_url hands the project to the team of whoever opens it and signs in, which is the "link that gives a role to whoever opens it" case from the new AGENTS.md rule, same as createInvitation.

Without it, offered() makes it a tool and the link lands in the model's context. A prompt-injected result could ask the agent to create a claim and post the URL somewhere.

Could you also add it to the integration test's list of operations that are not shown?

Comment on lines +126 to +128
- Every `DELETE` is destructive; a `POST` that removes, revokes or rolls back,
or that replaces what a project serves, as a deployment does, says so with
`x-zitadel-destructive: true` after its `x-zitadel-cli`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should overwriting a credential count as destructive too? setUserPassword (PUT /users/{user_id}/password) is offered as a tool without the marker, so an agent can replace any user's password without the person at the client being asked, and the plaintext password travels through the model as an argument. It cannot be undone, which is closer to a revoke than to an update.

Either mark it x-zitadel-destructive: true and widen this rule, or keep it off the tool list.

// shownArguments is arguments as a question shows them, empty when the call
// has none.
func shownArguments(arguments json.RawMessage) string {
var canonical map[string]any

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Decoding into any turns numbers into float64, here and in confirmationState. An integer above 2^53 is shown rounded, so the question names a different value from the one the API receives, and two calls that differ only beyond float precision share a state.

Unlikely with today's schemas, but a json.Decoder with UseNumber() in both places closes it.


// droppedKeyword reports a keyword left out of a tool's input schema: examples weigh much
// and constrain nothing, and vendor extensions mean nothing to a client.
func droppedKeyword(keyword string) bool {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

discriminator should be dropped too. It is OpenAPI-only, and its mapping values still point at #/components/schemas/... after the rewrite, so publishPolicy and evaluatePolicy ship tool schemas with refs that resolve to nothing. A client that resolves refs strictly may reject the tool.

// forwardedHeaders are what a tool call's request takes from the request that
// carried it: the credential, who the client says it is, and what a proxy in
// front of the server said about the connection.
var forwardedHeaders = []string{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The request ID does not carry over: the inner request gets none of the configured request_id_header (e.g. x-vercel-id on the cloud), so WithRequestContextMiddleware mints a new one per tool call. The audit event of a deleteUser done through MCP then cannot be found by the ID of the MCP request that carried it.

Forwarding the configured header (or the outer request ID) would tie them together.

Comment thread apps/api/internal/mcp/handler.go Outdated
// to send.
func challenging(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
scheme, token, _ := strings.Cut(r.Header.Get("Authorization"), " ")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: this splits on the first space, while the SDK's verify wants exactly two strings.Fields. Authorization: Bearer a b gets past here and the SDK answers 401 without WWW-Authenticate, the case this wrapper exists for. Parsing with strings.Fields the same way keeps the two in step.

OAuth server is unfinished and opens new endpoints to callers without a
credential. This endpoint does neither (§1).

## Non-goals

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.

Long-term, MCP-apps could be a good fit for our use-case, for example, rendering the login component directly on the MCP Host when editing the flow definition, flow steps diagram visualization, etc.


- The server answers the call with a question, and the client sends the call
again with the answer (the protocol's multi round-trip requests, revision
`2026-07-28`). On yes the request is sent. On no it answers with an error

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.

Is this revision already well adopted by clients?

every scope is shown 75 tools, about 124,000 bytes of JSON, with every
parameter's description cut to its first sentence and every example
dropped. A test holds the list under 130,000, so growth is a decision (open
question 4). A credential with fewer scopes is shown fewer.

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.

and the cloud serve the same endpoint. There is no second server in the CLI.
- **The server enforces the rules.** What an agent may call does not depend on
which client it uses or how that client was configured.
- **It sits outside the API's middleware chain**, as the OAuth server does: an

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.

How will the audit events look like? Can we distinguish request.api to/via /api/v1/mcp from normal API traffic?

…rd is replaced, and tie a tool call to its request

From the review of the MCP endpoint:

- `createProjectClaim` is marked `x-zitadel-returns-secret`: its `claim_url`
  gives the project to the team of whoever opens it and signs in, so it is no
  tool, as an invitation is none.
- `setUserPassword` is marked `x-zitadel-destructive`: the password it
  replaces cannot be put back. The endpoint asks the person at the client
  first, and so does `zitadel api setUserPassword`.
- A question shows a number, and binds it, as it was written. Read as a
  float, an integer past 2^53 was shown rounded and shared its state with its
  neighbours.
- A tool's schema drops OpenAPI's `discriminator`, whose mapping named
  components the schema does not hold.
- A tool call's request keeps the request ID of the MCP request that carried
  it, so its log line and its event are found by that ID.
- The bearer challenge reads the header as the protocol library does, so a
  header with a second token is challenged too.

The tool list now says `cacheScope: private` with a five-minute `ttlMs`. The
list depends on the credential, and the library's default would have called
it `public`.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
Raised in review as a later fit for the sign-in component and a flow's steps.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
… verb of their names

`main` added `createTeamMembership` and `deleteTeamMembership`, titled "Add a
user to a team" and "Remove a member from a team". An MCP client shows a
person the summary and a model the `operationId`, and a test of the endpoint
holds that the two open with the same verb. They are now "Create a team
membership" and "Delete a team membership"; their descriptions keep the
words a reader looks for.

With them the endpoint offers 76 tools, about 127,000 bytes of the 130,000
its list may weigh.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U

This branch was successfully deployed

1 active deployment
Preview — f8429a8f Deployed Dec 1, 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.

5 participants