Repository navigation
feat(api): let an MCP client choose tool sets, and reads only, by its URL - #3555
Conversation
… URL
The MCP endpoint lists every tool its credential's scopes cover, which a
client that loads every tool carries in full and counts against a cap of
its own. A person now narrows the list by the URL they configure the client
with, which a client that can set a URL and nothing else can do too:
/api/v1/mcp/x/{set,...} the tool sets named
/api/v1/mcp/readonly every set, reads only
/api/v1/mcp/x/{set,...}/readonly
A set is the operations of one of the spec's tags, in snake_case, or all of
them (all). A URL that names a set the endpoint lacks is refused with the
sets it has. What a URL does not list is not called: a write on a URL that
reads only, and a tool of a set the URL does not name, are refused before a
request is made, saying how the person lists it. The server's instructions
say which sets a connection lists and how to choose them.
A tool heavier than 16,000 bytes is no longer left out: it is in a set of
its own, named after it, listed only where the URL names it. That is
buildRelease (build_release) today.
A URL below the endpoint is a resource of its own: its challenge names its
metadata, served below the endpoint's, whose resource is that URL, as RFC
9728 §3.3 has a client check.
The budget becomes three checks: 16,000 bytes per tool, 80,000 bytes for
the list a default consent yields (every scope that reads), and at most 100
tools on a plain URL. The set names are contract, held by a test.
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmRZfCYDgfwMBn4935W
(cherry picked from commit 1c7a6e9)
…lient asks a token for it An MCP client connected to a URL that chooses tool sets, such as /api/v1/mcp/x/users/readonly, names that URL as the resource it asks a token for: the Go SDK takes the URL it connects to as the resource and requires the endpoint's metadata to name it exactly (RFC 9728 §3.3), and the TypeScript SDK asks for what the metadata names. The platform project's issuer refused it as invalid_target. ProtectedAPI.Narrowed names the identifiers whose URLs below them are the same API: the MCP endpoint's. The issuer reads such a resource as the endpoint at the authorization request, the code exchange and the refresh, so the token carries the endpoint as its audience and the API takes it as before. Only a path of lowercase letters, digits, underscores, commas and slashes is below the endpoint: a query, a fragment or a dot segment is still invalid_target, and no customer project's issuer narrows anything. The URL narrows what a client is offered; the scopes a person consents to remain what the token allows. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmRZfCYDgfwMBn4935W (cherry picked from commit d97fad6)
…question 4 §3 says how a person narrows the tool list by the URL a client connects to (the spec's tags as tool sets, and reads only, enforced at the call), that a heavy tool is listed only by name, and that the list's budget is three checks: 16,000 bytes per tool, 80,000 for the list a default consent yields, and 100 tools on a plain URL. §8 says a URL below the endpoint has metadata of its own, which the issuer reads as the endpoint. Open question 4 is answered, as Proposed, with the sources read on 2026-12-02, and the bare-body design that was built and taken out joins the rejected alternatives, with a smaller default list, a query or header form, and search-and-execute tools. The pending changeset for the endpoint says what a narrower URL lists. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmRZfCYDgfwMBn4935W (cherry picked from commit fada043)
…RL that lists it The server's instructions named the heavy tools' sets whatever the credential, and only the URL grammar. They now name each heavy tool the credential's scopes cover and the URL does not list, with the URL that lists it beside what this one lists (/api/v1/mcp/x/all,build_release), so an agent learns that buildRelease exists and how the person turns it on. A URL that reads only names none, since it never lists a write. ADR 092 §3 says plainly that a URL is no boundary of the credential, and how each of the budget's numbers was measured, ADR 094 step 5 included. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmRZfCYDgfwMBn4935W (cherry picked from commit 0903921)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 64f1d8e 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 |
ADR 092 §3 and its answer to open question 4 said step 5 opens about 25 more operations and would pass the 100-tool ceiling. It makes six operations tools that are none today (createProject, updateMyUser, completeProjectClaim, lookupInvitation, acceptInvitation, rejectInvitation), about 97 with the other sessions' additions: under 100, so the ceiling binds at the next addition after it. The other operations it opens to a person's token are tools already, and change only how many a person is shown. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmRZfCYDgfwMBn4935W (cherry picked from commit 435f0e8)
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. |
There was a problem hiding this comment.
🟡 Changes recommended
Set deduplication allows unauthenticated callers to exhaust CPU through quadratic work, and read-only refusal hints can point to URLs that still exclude the requested tool.
2 open issues
What changed in this PR
Adds URL-selected tool sets and read-only connections to the API’s MCP endpoint, while keeping credential scopes as the authorization boundary.
Changes:
- Filters tool lists and calls by URL, with explicit access to
buildRelease. - Supports narrowed URLs in OAuth discovery, authorization, token exchange and refresh.
- Updates contract documentation and tests for filtering, routing and tool budgets.
| File | Description |
|---|---|
docs/adrs/092-mcp-server.md |
Documents URL selection and revised budgets. |
apps/api/internal/oauth/token.go |
Normalizes narrowed resources during token requests. |
apps/api/internal/oauth/token_test.go |
Tests narrowed-resource code exchange. |
apps/api/internal/oauth/refresh_test.go |
Tests refresh with narrowed resources. |
apps/api/internal/oauth/authorize.go |
Recognizes narrowed platform resources. |
apps/api/internal/oauth/authorize_test.go |
Tests resource acceptance and rejection. |
apps/api/internal/mcp/sets.go |
Implements URL selection and guidance. |
apps/api/internal/mcp/sets_test.go |
Tests filtering, refusals and discovery. |
apps/api/internal/mcp/handler.go |
Enforces selections and serves resource metadata. |
apps/api/internal/mcp/handler_test.go |
Adds narrowed-connection test helpers. |
apps/api/internal/mcp/catalog.go |
Reads operation tags for tool sets. |
apps/api/internal/mcp/catalog_test.go |
Pins set names and revised budgets. |
apps/api/internal/api/integration_test/mcp_test.go |
Tests narrowed connections against the API. |
apps/api/cmd/server/server.go |
Mounts narrowed endpoints and metadata routes. |
apps/api/cmd/server/mux_test.go |
Tests endpoint routing and discovery. |
.changeset/mcp-endpoint.md |
Updates customer-facing release notes. |
Review effort: Balanced
| for name := range strings.SplitSeq(names, ",") { | ||
| switch { | ||
| case known == nil && !setNameSyntax(name): | ||
| return selection{}, fmt.Errorf("the MCP endpoint has no tool set %q: a set's name is lowercase letters, digits and underscores", | ||
| printable(name)) | ||
| case known != nil && name != allSets && !slices.Contains(known, name): | ||
| return selection{}, fmt.Errorf("the MCP endpoint has no tool set %q: its tool sets are %s, and %s for every one of them", | ||
| printable(name), strings.Join(known, ", "), allSets) | ||
| } | ||
| if !slices.Contains(chosen.sets, name) { | ||
| chosen.sets = append(chosen.sets, name) | ||
| } | ||
| } |
| if chosen.readOnly && !named.op.readOnly { | ||
| return failure(map[string]any{ | ||
| "message": named.op.id + " changes the project, and this connection reads only, so it was not sent", | ||
| "hint": "The person connects the client to the endpoint's URL without /" + readOnlySegment + " to let it write.", | ||
| }) | ||
| } |
main replaced the one budget on the whole tool list with three checks (#3555), so the raise this branch made to that budget goes. A person's own reads fit them: 86 tools on a plain URL, and 50 tools, 66,412 bytes, on the list a default consent yields. The tool-set tests expect the own reads in the users set, and ADR 092's measured figures say so. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
main replaced the one budget on the whole tool list with three checks (#3555), so the raise this branch made to that budget goes. The tool fits them: 80 tools on a plain URL, and the list a default consent yields is unchanged in count. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
…-api main chose tool sets by URL (#3555): the catalog keeps this branch's asksWhereItCan beside main's tags, and the one budget on the tool list gives way to main's three checks. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U


Context
The endpoint's tool list was at its limit: 141,563 of 142,000 bytes in 79 tools, and
buildReleasewas dropped for its size. The shape here was decided on 2026-12-02 after a check of current practice: clients that defer tool definitions (Claude, Cursor) no longer pay for a long list up front, clients that load everything limit the count of tools, and the closest comparable server lets the person narrow the list in the client's configuration. So every tool keeps its whole schema, and a person narrows by URL.Summary
/api/v1/mcp/x/{set,...}lists the named tool sets./readonly, after that or on its own, lists only the tools that read.allnames every set.buildRelease(37,150 bytes, over the 16,000 per-tool cap) is no longer dropped. It is in a set of its own,build_release, listed only where the URL names it.resourceis exactly that URL (RFC 9728 §3.3). The platform issuer reads such a URL as the endpoint at authorize, code exchange and refresh (ProtectedAPI.Narrowed), and only a path of lowercase letters, digits, underscores, commas and slashes below the endpoint is read that way. The token's audience and the API's audience check are unchanged. A query, fragment or dot segment staysinvalid_target.listBudget:.readscope): 43 tools and 61,226 bytes today;TestToolSetsAreTheSpecsTags: a renamed tag would break a configured URL.Validation
Run by the session that wrote the change, in its cloud container:
go test ./internal/mcp/ ./internal/oauth/ ./internal/api/;go test -run MCP ./cmd/server/.go test -tags sqlite_integration ./internal/api/integration_test/: 267 pass, including a narrowed URL against the real API (it lists the sets; a write on/readonlyis refused and nothing is created).go vet ./...and the repository's analyzers.oauth.enabled, driven by the official MCP Go SDK client with Claude Code's client metadata document, on/api/v1/mcp/x/users,teams/readonly: the challenge and the metadata name that URL, the client asksresource=<that URL>, and the issuer accepts it and redirects to sign-in. Before this change it answeredinvalid_target.resourceequal to the URL or a parent path, and asks for the metadata'sresource.go test ./...fails only the three console-embed mux tests, because the Console is not built in that container.Run again when opening this draft, on the four commits cherry-picked onto current main:
go vet ./internal/mcp/ ./internal/oauth/go test ./internal/mcp/ ./internal/oauth/go test -run MCP ./cmd/server/go test -tags sqlite_integration ./internal/api/integration_test/ -run MCPnode scripts/check-pr-title.mjs --title "…"Release notes / changeset
.changeset/mcp-endpoint.md(pending, extended;@zitadel/server). A client can connect to a narrower list by URL, andbuildReleaseis listed where the URL namesbuild_release.Notes
outputSchemawould add 374,041 bytes across 70 tools (listEventsandgetEvent47 KB each, from the event payload'soneOf), 2.6 times today's list. Not declared until event schemas can be summarized.getSchema("Returns a schema by ID.") would search better saying "user schema", which is open question 11's ground.TestToolSetsAreTheSpecsTagsmust be updated.https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
Generated by Claude Code