Skip to content

feat(api): offer an MCP client the operations that answer with a credential - #3542

Merged
fforootd merged 13 commits into
mainfrom
claude/mcp-secret-answers
Dec 2, 2026
Merged

fforootd merged 13 commits into
mainfrom
claude/mcp-secret-answers

Conversation

@fforootd

@fforootd fforootd commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Context

Summary

  • Before: the MCP endpoint offered no operation whose answer holds a credential (ADR 092 §4), so that none entered a model's context. An agent could not register an application, invite a person or start a project's claim.
  • Now: publishApplication, createInvitation and createProjectClaim are tools. The caller's credential and its scopes decide who is shown them, as for every other tool.
  • The marker words the tool instead of hiding it. x-zitadel-returns-secret adds 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.
  • Still out: the three operations with that marker that an application calls while a user signs in (createSession, exchangeHandoff, createAuthAttemptHandoff). They stay out by their plane (x-zitadel-plane: app), as before.
  • No question from the endpoint before such a call. ADR 092 §6's question reaches only clients on the newest protocol revision and never a machine, so asking would keep most callers from the operation. The guards are:
    • the scope the person consented to;
    • the client's own question before a tool that is not read-only.
  • cancelInvitation is 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 before 2026-07-28 cannot answer the question, so it could not end a link that leaked. An operation may now say x-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. cancelInvitation is the one operation marked, and a test names the marked ones. The CLI is unchanged and still asks.
  • Budget: the list grows from 76 tools (130,195 bytes with fix(api): name the client on OAuth events, and tell agents what a tool's first sentence leaves out #3537) to 79 (138,131). listBudget rises 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's fields argument on the other tools (about 141,600 combined).
  • Docs: ADR 092 (TL;DR, §3 numbers, §4 amendment, §8, Risks, open question 9), the ADR index row, the OpenAPI AGENTS.md, docs/quick-start/configuration.md, and the pending .changeset/mcp-endpoint.md.

Validation

  • go test ./internal/mcp/ ./internal/api/ ./cmd/server/ passes.
    • TestToolsThatAnswerWithACredentialSaySo holds that exactly the three operations carry the sentence, and that the application-plane ones are no tools.
    • TestEndpointListsTheToolsTheCredentialsScopesCover holds that a credential with every scope is shown them and one with user.read is not.
    • TestCatalogMarksWhatIsSentUnasked and TestUnaskedDestructiveCallIsSentFromAClientThatCannotAsk hold that cancelInvitation, 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 in TestMCPEndpoint call each tool against the real API handler with a project secret and read the credential from the answer: the client's secret from publishApplication, the claim_url from createProjectClaim, and the link from createInvitation on a claimed project.
  • gofmt (the toolchain's), go vet with and without the integration tag, scripts/go-lint.mjs, pnpm run check-openapi-rules, scripts/check-adrs-index.mjs and scripts/check-pr-title.mjs pass.
  • Not run:
    • The Postgres and Spanner lanes.
    • A real MCP client against a running server.

Release notes / changeset

  • Changeset: edits the pending .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

https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U


Generated by Claude Code

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
@vercel

vercel Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
cloud Ready Ready Preview Dec 2, 2026 5:35am UTC

Request Review

@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-12-02T02:04:58.552334Z 5012ef0 PR opened
ℹ️ 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.

@zitadel-kanban zitadel-kanban Bot moved this to Inbox in Engineering Kanban Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

🦋 Changeset detected

Latest commit: dc94684

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/cli Minor
@zitadel/testing Minor
@zitadel/server-darwin-arm64 Minor
@zitadel/server-darwin-x64 Minor
@zitadel/server-linux-arm64 Minor
@zitadel/server-linux-x64 Minor
@zitadel/server-win32-x64 Minor
@zitadel/api Minor
@zitadel/components Minor
@zitadel/config Minor
@zitadel/sdk-angular Minor
@zitadel/sdk-core Minor
@zitadel/sdk-next Minor
@zitadel/sdk-nuxt Minor
@zitadel/sdk-qwik Minor
@zitadel/sdk-qwik-router Minor
@zitadel/sdk-react Minor
@zitadel/sdk-solid Minor
@zitadel/sdk-solid-start Minor
@zitadel/sdk-svelte Minor
@zitadel/sdk-sveltekit Minor
@zitadel/sdk-tanstack-start Minor
@zitadel/sdk-vue Minor
@zitadel/cloud Patch
@zitadel/client-sdk-contract Patch
@zitadel/server-sdk-contract Patch

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

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

…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
Base automatically changed from claude/festive-hamilton-y0f0dx to main December 2, 2026 05:28
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
Copilot AI balanced review requested due to automatic review settings December 2, 2026 05:29
@fforootd
fforootd enabled auto-merge December 2, 2026 05:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The 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 cancelInvitation bypass 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

Comment thread apps/api/api/openapi/AGENTS.md Resolved
Comment thread docs/adrs/README.md Resolved
…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
@fforootd
fforootd added this pull request to the merge queue Dec 2, 2026
Merged via the queue into main with commit 09c3cda Dec 2, 2026
17 checks passed
@fforootd
fforootd deleted the claude/mcp-secret-answers branch December 2, 2026 05:46
@github-project-automation github-project-automation Bot moved this from Inbox to Done in Engineering Kanban Dec 2, 2026
fforootd pushed a commit that referenced this pull request Dec 2, 2026
…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
fforootd pushed a commit that referenced this pull request Dec 2, 2026
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
fforootd pushed a commit that referenced this pull request Dec 2, 2026
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
fforootd pushed a commit that referenced this pull request Dec 2, 2026
#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
fforootd pushed a commit that referenced this pull request Dec 2, 2026
Picks up #3546 and #3547, which landed after #3542.

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

This branch was successfully deployed

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

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants