Repository navigation
fix(api): name the client on OAuth events, and tell agents what a tool's first sentence leaves out - #3537
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
|
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: e95767c 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 |
There was a problem hiding this comment.
🟡 Changes recommended
The new patch changeset should be folded into the existing unreleased feature changesets, retaining their higher version bumps as required by the repository guidelines.
1 open issue
What changed in this PR
This PR adds OAuth client attribution to audit events and clarifies MCP tool guidance for agents using the API.
Changes:
- Populate OAuth events’
client_id, with regression assertions. - Add concise agent notes to three tools and clarify default project selection.
- Update documentation, the tool-list budget, and release notes.
| File | Description |
|---|---|
docs/design/api/events-catalog.md |
Documents OAuth client attribution. |
docs/adrs/092-mcp-server.md |
Records agent notes and budget changes. |
apps/api/internal/service/session.go |
Attributes issued tokens to clients. |
apps/api/internal/service/refresh_grant.go |
Attributes refresh-grant events to clients. |
apps/api/internal/service/refresh_grant_test.go |
Checks refresh-grant client attribution. |
apps/api/internal/service/auth_request.go |
Attributes authorization-request events to clients. |
apps/api/internal/service/auth_request_test.go |
Checks authorization-event client attribution. |
apps/api/internal/mcp/handler.go |
Appends notes and clarifies project defaults. |
apps/api/internal/mcp/catalog.go |
Reads agent notes from OpenAPI. |
apps/api/internal/mcp/catalog_test.go |
Checks notes and adjusts list budget. |
apps/api/internal/audit/emit.go |
Supports explicit client attribution. |
apps/api/internal/audit/emit_test.go |
Checks client override and fallback. |
apps/api/api/openapi/endpoints/search/methods.yaml |
Explains search scope and limits. |
apps/api/api/openapi/endpoints/projects/by_id/members/methods.yaml |
Explains platform-operator omission. |
apps/api/api/openapi/endpoints/events/methods.yaml |
Adds sign-in investigation guidance. |
apps/api/api/openapi/bundled/openapi.json |
Includes generated agent notes. |
apps/api/api/openapi/AGENTS.md |
Defines agent-note authoring guidance. |
.changeset/oauth-events-client-and-agent-notes.md |
Adds server release notes. |
Review effort: Balanced
…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
…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
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
Picks up #3537, which landed on main first. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U

Context
client_id,searchfound nobody, and "who is admin here?" got an empty answer with no explanation.Summary
The client on the events the OAuth endpoints write (first commit)
client_idfrom the request and named the client only in the payload. FilteringGET /eventsbyclient_idfound every call Claude made but none of the tokens it was issued.audit.EmitSpectakes aClientID, which overrides the request's. It is set on:auth.request.created: the client the authorization request names;auth.request.exchange.failed: the client that presented the code;auth.token.issuedandauth.token.revokedof a code or refresh grant: the grant's client.client_id, so no event schema changes. The events catalog says which client each names.What a tool's first sentence leaves out (second commit)
searchwithoutproject_idreads only the 10 newest projects a person can act on. The admin lives in the platform project, which isn't among them, so the search found nothing.listProjectMembersreads owning teams and grants. Platform operators hold neither, so the platform project's list was empty, with no word why.listEventsdidn't say which of a sign-in's events means what, or that onlyrequest.apicarries the caller's IP.x-zitadel-agent-note: one or two sentences the tool's description adds after the method and path. These three operations have one. A test holds each note under 400 bytes, on an offered operation, ending a sentence.project_idon a tool: every tool described it as defaulting to the credential's project, also onsearch, which declares its own optional one. An operation's own optionalproject_idnow carries that operation's words; the default is said where the endpoint fills it in and on the document's shared optional one.listEventsandlistProjectMembersnow say in their descriptions what their notes say, as the OpenAPI rules promise.project_idleft out "is that credential's project". For a person's token that is their home project, which holds their account and not necessarily their work. They now say so.AGENTS.mddescribe the note.Validation
internal/audit,internal/service,internal/mcpandcmd/cloud-launcherpass.client_idassertions inauth_request_test.goandrefresh_grant_test.gofail (42 failed assertions) with the service change stashed.TestToolDescriptionCarriesTheAgentNoteandTestAgentNotesStayShort.go test -tags sqlite_integration ./internal/api/integration_test/ -run 'OAuth|Code|Event|Refresh|MCP'passes.turbo run generate --filter=@zitadel/serverand--filter=@zitadel/api: only the bundled spec changed.pnpm run check-openapi-rulespasses.turbo run lint --filter=@zitadel/server --continue: 14 of 15 tasks pass.formatfails oninternal/flowengine/sso_test.go, a file this PR doesn't touch. The container'sgofmtis older than the toolchain;$(go env GOROOT)/bin/gofmt -lis clean.go veton the changed packages andscripts/go-lint.mjspass.node scripts/check-pr-title.mjspasses.Release notes / changeset
.changeset/oauth-events-client.md(@zitadel/server, patch). The events the released authorization and token endpoints write name their client inclient_id..changeset/README.mdasks:.changeset/oauth-refresh-tokens.md: the refresh grant's events name its client..changeset/mcp-endpoint.md: a tool's description adds a note where the first sentence would mislead.Notes
fieldsargument on MCP tools: feat(api): let an MCP tool return only the fields an agent names #3540, stacked on feat(api): offer an MCP client the operations that answer with a credential #3542, which is stacked on this PR.searchheld to the token's scopes in fix(api): hold a person's search to the types its token's scopes cover #3546.listProjectMembersnote is an interim. It says operators aren't listed. ADR 094 (docs: decide the project permission model under the platform root #3539) proposeslistPlatformOperatorsfor reading who operates the platform.https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
Generated by Claude Code