Repository navigation
feat: Add MCP endpoint to serve API operations as tools - #3480
Conversation
…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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: f8429a8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 27 packages
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
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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
There was a problem hiding this comment.
🟡 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
| 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 { |
There was a problem hiding this comment.
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
| if droppedKeyword(keyword) { | ||
| continue |
| 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
left a comment
There was a problem hiding this comment.
looks good, some small comments
| @@ -1,6 +1,6 @@ | |||
| post: | |||
| operationId: createProjectClaim | |||
There was a problem hiding this comment.
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?
| - 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`. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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{ |
There was a problem hiding this comment.
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.
| // 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"), " ") |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Does it mean the list of tools can't be cached?
https://blog.modelcontextprotocol.io/posts/2026-07-28/#list-results-are-cacheable
| 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 |
There was a problem hiding this comment.
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


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.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 (deleteGrantwas titled "Revoke a grant"), and a test holds that a tool's title opens with the verb of its name.mcp.enabled(NEXTGEN_MCP_ENABLED) turns the endpoint off.project.writeas 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).2026-07-28). A client that cannot ask is refused, and the request is not sent.createDeploymentis now marked destructive in the spec, asrollbackDeploymentwas, since both replace what a project serves.zitadel api createDeploymentasks first for the same reason;zitadel deploy,deployment createandpreviewalready asked on their own terms.setUserPasswordis marked destructive too: the password it replaces cannot be put back, and whoever sets one can sign in as that user.cacheScope: privateand attlMsof five minutes, since the credential's scopes decide the list. The protocol library's default would have called itpublic.request.apievent are found by theX-Request-Idthe client was answered with.Three new markers in the OpenAPI source make this readable from the spec:
x-zitadel-read-only(aPOSTthat changes nothing),x-zitadel-plane: appandx-zitadel-returns-secret.@zitadel/api's generated operation table carries them asreadOnly,planeandreturnsSecret.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:
buildReleasewould 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/apiunless noted:go vet ./...go test ./internal/mcp/ ./cmd/server/ ./cmd/cloud-launcher/ ./internal/api/ -count=1go test -tags sqlite_integration ./internal/api/integration_test/ -count=1 -timeout 20mnode scripts/go-lint.mjs(repo root)turbo run check-generate openapi --filter=@zitadel/serverandnode scripts/check-go-work.mjs(repo root)/api/v1/mcpanswers 401 to a request without a credential, and/mcpat the root answers 404.Bearerchallenge, 404 withNEXTGEN_MCP_ENABLED=false, and with a real project secretgetProject,queryTeams,createTeam, anddeleteUserrefused 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/sdk1.32.2 speaks no protocol revision after2025-11-25, so a client built on it can list and call tools and is refused on the destructive ones;@modelcontextprotocol/client2.4.0 speaks2026-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=1andnode scripts/go-lint.mjs:x-(a user schema'sx-auth-methods,x-identifier,x-display) or are calledexample; the filter for vendor extensions had dropped them, andpublishSchemarequired a property it no longer described;After the reviews by people, one more commit (aff8f67) and a line in ADR 092's non-goals:
createProjectClaimis no tool any more (x-zitadel-returns-secret), which decides ADR 092's open question 9;setUserPasswordasks first (x-zitadel-destructive), on the endpoint and onzitadel api setUserPassword;discriminator, whose mapping named components the schema does not hold, and a test holds that no tool's schema names one;Bearer a bis challenged too;Then
mainwas merged in, because CI tests the merge: it had gainedcreateTeamMembershipanddeleteTeamMembership, 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=1andgo 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 includescheck-generate),pnpm run check-openapi-rules,node scripts/check-changesets-status.mjs, and inapps/clithe unit tests of theapicommand and the backend client.Release notes / changeset
.changeset/mcp-endpoint.md— the server serves its API as MCP tools at/api/v1/mcp(experimental) (@zitadel/server).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/deployment-asks-first.md—createDeploymentandsetUserPasswordare marked destructive, so the MCP endpoint andzitadel apiask first (@zitadel/server,@zitadel/api,@zitadel/cli)Notes
maintook 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.v1contract's operations (ADR 077 §3). The branch first served it at/mcp; ADR 092 lists that as a rejected alternative.vercel.jsonalready sends/api/to the server andmcp.enableddefaults to on, so the hosted cloud serves the endpoint once this merges, with no routing change. The server readsNEXTGEN_MCP_ENABLED=falseto hold it back. A test pins that/mcpat the root stays the website's.api.github.com/modelcontextprotocol/go-sdkv1.9.0, the official Go SDK.zitadel mcpcommand to the CLI and then reverted it. The only CLI change left in the diff is six lines inapps/cli/src/lib/backend/services/operation.ts, which give the CLI'sOperationtype the three new marker fields.https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
Generated by Claude Code