Repository navigation
feat(api): offer an MCP client the operations that answer with a credential - #3542
Conversation
The OAuth endpoints authenticate no bearer, so the events they write took an empty client_id from the request and named the client only in the payload. A filter on client_id then missed the tokens a client was issued. EmitSpec takes the client, and auth.request.created, auth.request.exchange.failed and the auth.token.issued and auth.token.revoked of a code or refresh grant set it. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
The MCP endpoint shows only the first sentence of an operation's description, and agents guessed wrong from it: search without project_id read only a person's newest projects, listProjectMembers left out platform operators, and listEvents said nothing about how to read one sign-in. An operation may now say the rest in x-zitadel-agent-note, which the tool's description adds; the list's budget rises to 132,000 bytes for it. The server's instructions no longer say that a project_id left out is always the credential's project without saying what that is for a person. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
…ential The MCP endpoint offered no operation whose answer holds a credential, so an agent could not register an application, invite a person or start a project's claim. Zitadel is to be driven by agents, with the caller's credential deciding what it may do, so publishApplication, createInvitation and createProjectClaim become tools. x-zitadel-returns-secret now words the tool: its description says the answer holds a credential, to pass to the user and write nowhere else. The three such operations an application calls while a user signs in stay out by their plane. The list's budget rises to 142,000 bytes for the three tools. 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.
|
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. |
🦋 Changeset detectedLatest commit: dc94684 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 |
…ng changesets The MCP endpoint and refresh tokens have not been released, so what this branch changes about them belongs in their pending changesets (.changeset/README.md). The authorization and token endpoints have been, so the client on their events keeps a patch changeset of its own. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
…into claude/mcp-secret-answers # Conflicts: # .changeset/mcp-endpoint.md
… three tools A review found the ADR's claim wrong that a client secret a tool returns is ended by rotating it: only a retry with the request's Idempotency-Key replaces a secret, and a tool sends no header. The ADR now says what ends each credential, the operator's reference no longer says such an operation is never a tool, and the amendment no longer names a guard that only #3543 adds. createInvitation and createProjectClaim are now called through their tools against the real API. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
…in full A review found two places where the MCP tools still misled. Every tool described project_id as defaulting to the credential's project, also on search, which declares its own optional one and reads a person's projects when it is left out: an operation's own optional project_id now carries that operation's words. And the descriptions of listEvents and listProjectMembers did not say what their agent notes say, though the OpenAPI rules promise they do: both now say it. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
…into claude/mcp-secret-answers # Conflicts: # docs/adrs/092-mcp-server.md
…s are kept The note on a tool that answers with a credential told an agent to pass it to the user and write it nowhere else. A coding agent's proper place for a client secret is the store the user keeps secrets in, such as the app's env file, so the note now allows that. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
… question The endpoint asks the person at the client before a destructive call and refuses the call from a client that cannot ask. cancelInvitation is what ends an invitation's link, which createInvitation now hands to an agent, so a client on an older protocol revision could not end one that leaked. An operation may now say x-zitadel-unasked: the endpoint sends its call as it is. Its tool keeps the protocol's destructive hint, so a client can ask its own user, and no longer says the user is asked. cancelInvitation is the one operation marked, and a test names the marked ones, since each is a decision. The CLI is unchanged and still asks. ADR 092 also records that a client secret is to be replaced through an operation of its own, in a later change. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
Picks up #3545, which the base branch did not hold. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
#3537 landed on main as one commit. This branch already holds its changes through the old base branch, so the merge takes nothing from it: it only records main as an ancestor, so that the pull request shows its own change. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
There was a problem hiding this comment.
🟡 Changes recommended
The documentation extends the confirmation-bypass rule beyond the allowed cancelInvitation exception while still promising confirmation for every destructive call.
2 open issues
What changed in this PR
Expands the server’s MCP endpoint so agents can register applications, create invitations, and start project claims using the caller’s existing permissions.
Changes:
- Exposes three credential-returning tools with credential-handling warnings.
- Lets
cancelInvitationbypass server confirmation while retaining its destructive hint. - Updates tests, tool-list budget, documentation, and release notes.
| File | Description |
|---|---|
docs/quick-start/configuration.md |
Explains new tools and the confirmation exception. |
docs/adrs/README.md |
Updates the MCP decision summary. |
docs/adrs/092-mcp-server.md |
Records behavior, budget, and credential risks. |
apps/api/internal/mcp/handler.go |
Adds credential warnings and conditional confirmation. |
apps/api/internal/mcp/handler_test.go |
Tests scope filtering and unconfirmed cancellation. |
apps/api/internal/mcp/catalog.go |
Allows credential-returning tools and reads the exception marker. |
apps/api/internal/mcp/catalog_test.go |
Tests catalog rules and raises the list budget. |
apps/api/internal/api/integration_test/mcp_test.go |
Tests credential responses through real API handlers. |
apps/api/api/openapi/endpoints/invitations/by_id/methods.yaml |
Marks cancellation as exempt from MCP confirmation. |
apps/api/api/openapi/bundled/openapi.json |
Includes the marker in the bundled contract. |
apps/api/api/openapi/AGENTS.md |
Updates guidance for operation markers. |
.changeset/mcp-endpoint.md |
Updates pending MCP release notes. |
Review effort: Balanced
…n is promised The ADR index and ADR 092's summary still said every destructive call is confirmed. The OpenAPI rules read as if any removal that ends access should be marked x-zitadel-unasked; they now say only cancelInvitation is, by ADR 092 §6, and name the test that holds it. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
…cope Picks up what landed on main in between: #3541, #3539, #3543 and #3542. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
Takes x-zitadel-unasked and operation.asks() beside the fields argument: the catalog keeps both new fields, the server's instructions keep both sentences, and the changeset says both. 79 tools weigh 141,563 bytes, so ADR 092 §3's combined figure stands. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
Picks up what landed on main in between: #3538, #3541, #3539 and #3543. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
#3542 landed on main as one commit. This branch already holds its changes through the old base branch, so the merge takes nothing from it: it only records main as an ancestor, so that the pull request shows its own change. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
Picks up #3546 and #3547, which landed after #3542. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U

Context
createInvitation).Summary
publishApplication,createInvitationandcreateProjectClaimare tools. The caller's credential and its scopes decide who is shown them, as for every other tool.x-zitadel-returns-secretadds one sentence to the tool's description: the answer holds a credential, to pass to the user or store where they keep secrets, and to write nowhere else.createSession,exchangeHandoff,createAuthAttemptHandoff). They stay out by their plane (x-zitadel-plane: app), as before.cancelInvitationis sent without the endpoint's question (owner's decision, 2026-12-02). It is what ends an invitation's link, and a client on a protocol revision before2026-07-28cannot answer the question, so it could not end a link that leaked. An operation may now sayx-zitadel-unasked: true: the endpoint sends its call as it is. The tool keeps the protocol's destructive hint, so a client can still ask its own user, and its description no longer says the user is asked.cancelInvitationis the one operation marked, and a test names the marked ones. The CLI is unchanged and still asks.listBudgetrises from 132,000 to 142,000, which also leaves room for feat(api): let an MCP tool return only the fields an agent names #3540'sfieldsargument on the other tools (about 141,600 combined).AGENTS.md,docs/quick-start/configuration.md, and the pending.changeset/mcp-endpoint.md.Validation
go test ./internal/mcp/ ./internal/api/ ./cmd/server/passes.TestToolsThatAnswerWithACredentialSaySoholds that exactly the three operations carry the sentence, and that the application-plane ones are no tools.TestEndpointListsTheToolsTheCredentialsScopesCoverholds that a credential with every scope is shown them and one withuser.readis not.TestCatalogMarksWhatIsSentUnaskedandTestUnaskedDestructiveCallIsSentFromAClientThatCannotAskhold thatcancelInvitation, and no other operation, is sent from a client that cannot ask; both fail without the spec's mark.go test -tags sqlite_integration ./internal/api/integration_test/passes. Three new cases inTestMCPEndpointcall each tool against the real API handler with a project secret and read the credential from the answer: the client's secret frompublishApplication, theclaim_urlfromcreateProjectClaim, and thelinkfromcreateInvitationon a claimed project.gofmt(the toolchain's),go vetwith and without the integration tag,scripts/go-lint.mjs,pnpm run check-openapi-rules,scripts/check-adrs-index.mjsandscripts/check-pr-title.mjspass.Release notes / changeset
.changeset/mcp-endpoint.md(@zitadel/server, minor; the endpoint is unreleased). Its sentence that such an operation "is never a tool" now says the tool's description says so.Notes
createInvitationonce fix(api): take a person's token on the operations a Console session may call, and guard invitations with the grant scopes #3538 merges.publishApplicationandcreateProjectClaimaccept only a project secret; opening them to a person, a personal access token or a machine is ADR 094's work (docs: decide the project permission model under the platform root #3539).cancelInvitation, which every client can now call;Idempotency-Keyreplaces it, and a tool sends no header. Decided on 2026-12-02: an operation of its own follows in a later PR.fieldsand a credential: feat(api): let an MCP tool return only the fields an agent names #3540 gives these three tools nofieldsargument, so a path cannot cut a credential that is shown once out of its answer.https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
Generated by Claude Code