Repository navigation
fix(mcp): authorize client-registered MCP tools in session capability set - #1627
Merged
Merged
Conversation
…aluator Every existing client-MCP test (client_mcp_scenario_test.go) leaves Config.RootAuthority unset, so session.Authority is never bound (Provenance is empty) and authorizeExecution's first check skips enforcement entirely. Those tests pass identically whether or not a mounted tool is in the capability set - they cannot see the bug the previous commit fixed. Add a fixture that binds a real root authority and wires the real localauthority.Evaluator (mecated's default), then a test asserting a client-mounted tool call actually succeeds under it. Verified this test fails with exactly production's "denied by authority: tool is absent from the capability set" when the capability-set widening is disabled, and passes with it restored. Co-Authored-By: Claude Sonnet 5 <[email protected]>
kantord
marked this pull request as ready for review
September 16, 2026 12:09
samuv
requested changes
Sep 16, 2026
samuv
left a comment
Contributor
There was a problem hiding this comment.
Thanks for tracking this down. The authority change is headed in the right direction. I found one CI-blocking stale SDK expectation and one catalog-to-authority snapshot consistency issue, both noted inline.
sdk/typescript/e2e/tool.e2e.test.ts had a test deliberately asserting the OLD (buggy) denial as correct, with a comment explicitly saying "so the eventual RootAuthority widening has a failing test to flip" (introduced in #1111/#1122, M3 close-out). The previous two commits are exactly that widening, so CI's offline SDK e2e caught it: this test still expected the call denied. Updated it to assert the tool is now actually invoked and its real result reaches the model, using the same fixture/assertions as the file's existing happy-path test, still under the real "local" evaluator (not noop) so it keeps exercising the authorization path, not just mount+dispatch. Verified locally against a same-checkout mecated build. Co-Authored-By: Claude Sonnet 5 <[email protected]>
… second manager read Addresses review feedback from @samuv on #1627: mountedClientMCPToolNames called mgr.Servers()[].Tools() independently, AFTER assembleCatalog had already registered those same tools into the session's Catalog via a separate mcp.Register(cat, s.clientMgr.Tools()) call. Server.Tools() lazily refreshes on a tools/list_changed notification, so those two reads of the client MCP manager could disagree for a server whose tool list changes between catalog assembly and authority minting: the catalog would still advertise tool A (the earlier snapshot) while the authority list named tool B (a later one), and a call to A -- the only tool the model can actually see -- would be denied. That reproduces this fix's original bug for any dynamic client MCP server. assembleCatalog already snapshots the catalog's name set before and after mounting client MCP (classifyAdded, for classification purposes); reuse that same before/after diff to name the authorized tools instead, so the set is authoritative by construction -- it cannot drift from what the model was actually offered, because it comes from the exact same registration pass. assembleCatalog now returns this list as a third value (nil on the build-time/shared call, which never sets clientMgr); mountedClientMCPToolNames is removed, and its call site now threads the catalog-derived list straight into SessionEngineResult.MountedClientMCPTools. Verified: go build/vet clean, internal/app + internal/adapter/server suites pass, and the SDK e2e test added in the previous commit still passes against a rebuilt same-checkout mecated. Co-Authored-By: Claude Sonnet 5 <[email protected]>
samuv
approved these changes
Sep 16, 2026
samuv
left a comment
Contributor
There was a problem hiding this comment.
Thanks for addressing both comments. I rechecked the catalog-derived tool snapshot and the updated SDK E2E, and both fixes look good. Focused authority and catalog tests pass.
This was referenced Sep 21, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
client.tool()(SDK) correctly mounts a per-session client-provided MCP server and dispatches calls to it, but every call was denied by the authority evaluator:Root authority is minted once per session kind, from the static build-time catalog plus the operator-global MCP manager (
mintRootAuthority) — it has no visibility into a session's own client-mounted MCP servers, which don't exist until that session is created. Only--authority-evaluator noop(test/demo only) happened to skip the check, which is why the SDK's owncallback-tool.tsexample "worked."SessionEngineResult.MountedClientMCPTools(populated by the newmountedClientMCPToolNames, mirroring the existing per-servermountedClientMCPNames) and fold it into the minted authority insetPerSessionLabels, the same wayDebugMCPToolsalready is for debug sessions.client_mcp_authority_test.go) using a fixture that binds a real root authority and wires the reallocalauthority.Evaluator— every existing client-MCP test leavesConfig.RootAuthorityunset, so authority is never bound and enforcement never engages, meaning none of them could have caught this. Verified the new test fails with production's exact error message when the fix is reverted, and passes with it restored.Test plan
go build ./...go test ./internal/adapter/server/... ./internal/app/...— all passmecated(not just Go tests): unmodified binary denies a realclient.tool()call; binary built from this branch executes it and returns the real tool result🤖 Generated with Claude Code