Skip to content

feat(identitybroker): limit each agent's gateway calls to its definition's tools - #2937

Merged
jhrozek merged 28 commits into
mainfrom
feat/agent-tool-limit
Nov 23, 2026
Merged

jhrozek merged 28 commits into
mainfrom
feat/agent-tool-limit

Conversation

@rdimitrov

@rdimitrov rdimitrov commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Closes #2842. Part of #2851.

With the identity broker on, each gateway call must now be inside the acting agent's tool limit: its definition's, narrowed by the limit of the agent that started it. Before this, the broker accepted any tool. It implements the decision posted on #2842: resolve each definition's limit against the gateway's servers, with no tool lists.

What changes

Identity broker (internal/identitybroker)

  • Ceiling, a new value type: the servers an agent may call, each with the tools on it the agent may not. The zero value allows nothing. DefinitionRecord carries one.
  • The definition loader resolves each definition's ceiling against the servers the gateway routes. It applies the harness's meaning:
    • each server mcpServers references is granted whole, minus the tools disallowedTools names as mcp__<server>__<tool>;
    • tools selects no MCP tools in the harness, so it grants none;
    • an inline server, or a reference to a server the gateway doesn't route, grants nothing;
    • built-in definitions name every routed server.
  • Registration stores each instance's effective ceiling: its definition's, intersected with its parent's effective ceiling. It's computed once, when the instance first registers, and never recomputed or widened.
  • Check 7. AuthorizeCall refuses a call outside the effective ceiling with PERMISSION_DENIED. It runs after the gateway route check (check 6) and before any ID-JAG exchange. Each decision record names the ceiling it checked. A listing is allowed for any server the ceiling grants.
  • Names are unambiguous.
    • A tools/call must name its tool <server>.<tool>; any other name is now INVALID_ARGUMENT, so check 7 always sees a tool of the call's server.
    • Gateway server names are limited to letters, digits, and single underscores, as the MCP configuration already requires. A dot or a double underscore would let one server's name begin another's.

mecak8s

  • Named-definition helpers get gateway tools. A subagent or team member that runs a named definition now gets the session's gateway tools for the servers its definition references, minus excluded tools. This removes Helper agents: their own registered identity and broker MCP tools #2555's shortcut. Helpers that run no named definition still get all of them, narrowed by their parent's authority.
  • File-less team members keep to their definition. Since feat(identitybroker): start the broker from operator configuration and keys #2875 the broker runs without a local workspace, so outside Kubernetes execution its sessions are file-less. A file-less team member that names a definition now gets the file-less core tools its definition's tools and disallowedTools allow, its definition's own MCP servers instead of the server-global ones and CallMcpWithQuery, and its servers' gateway tools. It also reports the definition, so the broker applies the same limit. Before, it skipped the definition and registered as system/member.

Docs

  • mcp-authorization.md ("Definition-derived ceiling") records the resolution rule.
  • The identityBroker.enabled row in the mecak8s operator docs now describes the named-helper behavior and the limit.

Decisions to review

  1. A server is granted whole, minus excluded tools. This needs no tool list, which only a signed-in user can fetch and which can differ per user. A tool the gateway adds later is inside the limit of every definition that references its server, as it is in the harness today. This is the decision posted on Per-agent tool limit, checked by the broker #2842.
  2. No backfill code. The "Authority work switched on" row asks to backfill live instances. Broker state is in memory, so every instance is registered by this code and none predates the check. An instance with no ceiling would be denied every call, as the row requires.
  3. The ceiling check takes the tool's name on its server. It's a pure set lookup, so [Phase 3] Express the tool limit as generated Cedar policy #2849's Cedar policy replaces only checkCeiling's body. Splitting <server>.<tool> moved into request validation.
  4. The harness resolves the same rule again (defGatewayTools) rather than reading the broker's record, marked as a shortcut removed by Sessions run and register the exact definition revision #2548. A test runs one table of definitions through both and fails if they disagree.

Shortcuts

Found, not in this PR

API compatibility

Assessment: no wire change. No proto, gRPC, or HTTP surface changes. Ceiling, DefinitionRecord.Ceiling, CeilingServer, DecisionRecord.Ceiling, and the stricter AuthorizeCallRequest.Validate are in-process Go API in internal packages. #2559 (broker over gRPC) hasn't landed.

Behavior changes (for the release notes):

  • Gateway calls: with the broker on and a gateway configured, a call outside the agent's limit is refused. Production configures no identity broker gateway yet (Configure the embedded gateway's authorization server as AS-2 #2533), so no deployment sees this today.
  • File-less team members that name a definition, broker on or off: they now keep to the definition's tool limits. They lose the server-wide MCP tools and CallMcpWithQuery, connect the definition's own MCP servers, including inline ones, and drop the core and memory tools its tools list leaves out or its disallowedTools names.
  • The same members with the broker on: they now register under their definition rather than system/member. A member whose definition the broker didn't load (one not from --agents-dir) is refused at registration and doesn't start; before, it ran.

No major bump, no feature identifier, no approval needed.

Testing

Broker:

  • ceiling_internal_test.go:
    • exact pairs;
    • the empty ceiling;
    • listings;
    • an intersection property test (500 random pairs): the effective ceiling allows exactly what both its definition and its parent allow.
  • ceiling_test.go, through AuthorizeCall:
    • the main agent's built-in ceiling;
    • a read-only reviewer that cannot merge;
    • a deployer under the reviewer that cannot merge whatever its definition allows;
    • a built-in explorer under the deployer that cannot merge, so the exclusion carries down two levels;
    • an agent whose ceiling is empty registers and is refused every call;
    • refusals record the ceiling and make no exchange;
    • check 6 runs before check 7;
    • a tool not named for its server is INVALID_ARGUMENT.
  • loader_test.go: resolution against the routed servers, including an inline server, an unrouted reference, tools naming a routed server's tool, exclusions, built-ins, and no servers.

Harness and broker agree: internal/app TestDefGatewayToolsAgreesWithTheBrokersCeiling runs one table of definitions through both parsers and both rules.

End to end (cmd/mecak8s, real AS-1, AS-2, and the embedded vMCP):

  • A named subagent referencing the server calls its tool under its own identity.
  • A named subagent excluding the tool, and one referencing no server, never reach the gateway.
  • The same for a named team member, both cases, in a file-less session. The named-subagent cases run on the Redis filesystem, the one workspace the broker allows offline since feat(identitybroker): start the broker from operator configuration and keys #2875.
  • internal/app: a named team member with a filesystem, through the real member factory, gets its servers' gateway tools and never runs the excluded one; a file-less named member keeps to its definition's tools and reports the definition, while a generic one keeps the whole file-less surface. From fix(app): follow-ups to the agent tool limit #2956: a file-less member with a tools list keeps only those core tools, closes without a harness generation, and a definition loaded from disk has its excluded tool refused at AuthorizeCall; ceiling_test.go keeps the ceiling when agents register again in a reopened broker session.

Mutation checks. Each was applied, a test failed, and the code was restored:

Mutation Caught by
Intersecting with the parent's definition ceiling instead of its effective one The three-level test
Dropping the exclusion rule on either side The agreement test
Dropping the member path's gateway tools The team test

Dropping the harness catalog's exclusion alone is not caught. The engine's capability set excludes the tool too, so that mutant behaves the same.

Gates:

  • task lint and task docs pass.
  • Touched packages pass go test -race: internal/identitybroker/..., internal/adapter/mcpbroker, internal/adapter/server, internal/agentcredential/..., cmd/mecak8s, and internal/app.

Real use, local: I rebuilt mecak8s and ran it with the broker on. A subagent and a Team-tool team, whose second member runs a named definition, registered and reported their delegations with no broker warnings. The binary has no flag that turns on a gateway, so the gateway path is proven by the end-to-end tests above.

Panel review (spec, standards, tests, security, architecture, duplication, reuse) found no blockers. I fixed:

  • the stale operator-docs sentence;
  • the missing harness and broker cross-check (two reviewers);
  • the missing three-level, empty-ceiling, tools, and team-exclusion tests;
  • splitting <server>.<tool> inside the policy check;
  • server names that could overlap;
  • small simplifications.

After review

The review's findings and my answers are in the review reply. Two agents also checked each finding against the design independently. Changes from it:

Sign-off on the resolution rule is requested on #2842.

🤖 Generated with Claude Code

rdimitrov and others added 7 commits November 20, 2026 19:04
The broker now records runs and delegations per broker session and
applies design step (6) checks 4 and 5 to every AuthorizeCall:

- ReportDelegation records a delegation from a run of one agent to a new
  run of another, with the design's six checks in order. An unseen
  delegating run is recorded as a root run of a root instance.
- A call's run must be bound to the acting agent and act under the
  delegation it names; a new run naming no delegation needs a root
  instance. The reported run owner must equal the run's owner and the
  grant's owner, in one function a later membership check can replace.
- A first call's run is recorded only once both checks pass.
- The grant records its user, and the ID-JAG record carries the
  delegation, run owner, and grant user.

mecak8s reports the runs it already knows:

- Every server run entry puts the session's run ID and owner on the
  engine context; a RunTeam call mints its own run of the root's main
  agent, owned by the root's owner.
- Each helper registration and resume reports a new delegation from its
  parent agent's current run and keeps it with the helper's credential.
- A gateway call names the main agent's run, or the helper's delegated
  run, and is refused when there is none, replacing the run serial
  stand-in.
- After a broker session reopens, every held delegation is reported
  again in its original order.

Part of #2554.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… none

Review follow-ups:

- A helper resumed by a parent with no run no longer keeps acting in its
  earlier run; its gateway calls fail closed, as documented.
- Tests pin that one delegation starts one run, that a resume with no run
  holds no delegation, and that rootedRunContext carries the session's
  run or masks the caller's.
- Shortcut notes name #2805 for runs across replicas; delegations are
  described as kept until the root is dropped, since the design gives
  them no end.
- The design's delegation report lists the refusal of a receiving run
  that is already recorded; Service and Core docs cover the delegated
  run a call can record and another workload's delegation report.
- Delegation IDs use rand.Text, as the broker's own IDs do.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ecks

A parallel branch, a Team tool member, a member of a team the API
creates and runs, and a subagent resumed after its root's broker session
reopened each call the gateway through mecak8s's startup, the real AS-1
and AS-2, and the embedded vMCP. A helper is not a root instance, so each
completed call proves mecak8s reported the delegation that started its
run and the broker accepted it. Skipping the report fails all four.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Once a session's run and delegation records reach their cap, a delegated
run whose record was forgotten is recorded again from its delegation, for
the delegation's receiving agent only, and a run whose own delegation was
forgotten can no longer delegate. Both refusals were reachable only after
forgetting, so no test failed when either was removed. The credential
holder's list of delegations to report again forgets its oldest entry at
its cap while each helper keeps its current delegation.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- One deniedError helper for credential, run and delegation refusals.
- Name the run owner shortcut where the server reads the session owner
  at each run entry (removed by #2569), and cite the run-owner draft by
  its full path.
- startTeamRootRun says that it starts the RunTeam run, not only opens
  the root's broker session.
- Tests: a shared createSession helper, sync.OnceValues for the
  late-loading mock script, and slices.Repeat for its padding.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ion's tools

The broker now checks design step (6) check 7: each gateway call's exact
server and tool must be inside the acting agent's effective ceiling.

- The definition loader resolves each definition's ceiling against the
  servers the gateway routes. A server the definition's mcpServers
  references is granted whole, minus the tools its disallowedTools names;
  tools selects no MCP tools, as in the harness. Built-ins name every
  routed server. No tool list is needed, since listing tools needs a
  user's grant.
- Registration stores each instance's effective ceiling: its definition's,
  narrowed by its parent's effective ceiling, computed once and never
  widened.
- Check 7 runs after the gateway route check and refuses with
  PERMISSION_DENIED, recording the ceiling it checked. A call whose tool
  is not named for its server is now an invalid request, and gateway
  server names are limited to letters, digits, and single underscores, so
  "<server>.<tool>" and "mcp__<server>__<tool>" each name one server.
- A helper that runs a named definition, as a subagent or team member,
  now gets the session's gateway tools for the servers its definition
  references, minus excluded tools, removing #2555's shortcut. A test
  checks the harness and the broker resolve each definition the same way.

Records the resolution rule in mcp-authorization.md and updates the
identity broker row in the mecak8s operator docs.

Closes #2842.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@ChrisJBurns ChrisJBurns 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.

Review against the agent identity design and #2842 / #2851. This lists only issues, gaps, and questions. Nothing here blocks the PR, and none of the correctness items is an authorization bypass; they all fail closed. Please address each one or reply with your reasoning.

Design and ticket gaps

  1. The ceiling resolves against the wrong server list (major). The #2842 decision, and this PR's edit to mcp-authorization.md ("Definition-derived ceiling"), say the loader resolves against the operator's MCP configuration (mcp.servers). The code resolves against cfg.IdentityBrokerGatewayServers (internal/app/identitybroker.go:489), which is a test seam that production leaves nil (internal/app/build.go:996). Either change the code, or say in the doc that this list stands in until #2533.
  2. The harness and the broker read different server lists (major). defGatewayTools filters the MCP broker's routed backends (cfg.helperTools); the broker uses the list in point 1. Nothing keeps the two equal. TestDefGatewayToolsAgreesWithTheBrokersCeiling gives both sides the same list, so it can't catch a mismatch.
  3. Resolution inputs aren't kept, so a restart can widen a ceiling (major). The design requires keeping the resolution inputs, and says restoration never recomputes or widens a ceiling (the "Process restart" row in the agent-definitions.md continuity table, and implementation.md "Cedar authorization…" bullet 3). The gateway server set is a hidden input: it isn't in DefinitionRef, the revision, or the provenance. Broker state is in memory, so after a restart the instance registers again and its ceiling is recomputed (agents.go:156). A longer server list then gives more authority under the same definition revision. "Never recomputed or widened" holds only within one process, and no shortcut marker records the gap.
  4. #2842's "Done when" items aren't met (major):
    • The cross-check against the harness's delegated-authority intersection (implementation.md "Cedar authorization…" bullet 3). The new test compares one definition's resolution only. It never compares parent-narrowed effective ceilings with what the harness gives a child. Built-ins aren't compared either: builtinCeiling (loader.go:357) versus readOnlyExplorerCatalog/writableExplorerCatalog.
    • Backfill. The "Authority work switched on" row and #2842 require live instances to be backfilled and marked. The PR argues none exist, but changes neither the row nor the ticket. Please record the exception, e.g. "not applicable while broker state is in memory; revisit with #2559".
  5. The #2842 decision has no sign-off (question). The decision on #2842 is a proposed comment, and the issue asks for review by the design's author. No sign-off is recorded, but the PR treats it as decided.
  6. The decision text and the code disagree (minor):
    • The decision says nothing has to parse mcp__<server>__<tool>, but resolveCeiling parses it (loader.go:383), and the server-name restriction exists because of that.
    • The sentence before the new paragraph in mcp-authorization.md still says "permitted server/tool pairs". So does implementation.md "Work breakdown" (~line 367). Granting a whole server, including tools it adds later, is a widening that the pair wording doesn't allow. Reconcile both places.
  7. Built-ins get every routed server (minor). builtinCeiling ignores its def, but #2842's scope says built-ins get their limit from their built-in fields. If a built-in later sets mcpServers or disallowedTools, the broker ignores them without saying so.
  8. Tool naming is now part of the broker's contract (minor). Validate returns INVALID_ARGUMENT for any tools/call tool not named <server>.<tool> (service.go:474). That ties broker validation to the embedded vMCP's naming. Gateway.Route returns (server, tool) in no fixed format, so an external gateway (#2812) that names tools differently would fail every call. The step (6) failure table in credentials-and-lifecycle.md has no row for this INVALID_ARGUMENT.
  9. Listings aren't limited in practice (minor). Nothing in production reaches the tools/list branch of check 7 (ceiling.go:132): ListTools uses the session's credential (mcpbroker/gateway.go:72) and never calls AuthorizeCall. Excluded tool names and descriptions are still listed. The design's "Tool discovery" paragraph wasn't updated either way.
  10. Ticket accuracy (minor):
    • The shortcut at internal/app/agentdefs.go:604 says it's "removed by #2548", but #2548's "Removes shortcut" list doesn't include it. Add it there.
    • "Cedar replaces only checkCeiling's body" understates #2849. Cedar also needs per-definition policy generation and a policy-based intersection, so the exported Ceiling type, intersect, and DefinitionRecord.Ceiling change too.
  11. Branch hygiene (minor):
    • #2939 is now merged. This branch still has the defDisallowsTool loop that #2939 removed, next to the new registerHelperTools call, so a rebase will conflict or duplicate it. The PR body still describes #2939 as pending.
    • "Closes #2842" doesn't link while the base is feat/run-delegations (closingIssuesReferences is empty). Check that the link appears after retargeting to main.
  12. Operator docs (minor). In user-docs/operating/mecak8s/identity-and-client-access.md, the identityBroker.enabled row has two problems:
    • "the tools of each server its mcpServers lists" is inaccurate. Only a server named by reference and routed by the gateway counts; inline entries grant nothing. The doc doesn't give the excluded-tool form mcp__<server>__<tool>, or say that tools selects no MCP tools (tools: [Read] plus mcpServers: [github] still gets every GitHub tool).
    • It describes a refusal that production can't reach yet, because no gateway is configured (#2533). Add a qualifier or link.

Correctness

  1. The harness and the broker name servers differently (minor). GatewayServer() returns route.backend (internal/adapter/mcpbroker/runtime.go:660), while check 7 uses the server name Gateway.Route() returns. These agree only because embeddedGateway.Route passes the backend name through unchanged. An external gateway that maps names differently would split the harness from the broker without any error. The doc comment on GatewayServer() is wrong as written.
  2. Check 7 depends on the reported DefinitionRef (minor). Because of the #2551 shortcut, a root can register as system/main and get every server. A child that registers as a built-in gets its parent's whole ceiling instead of its own narrower one. Please note this in the check 7 shortcut comment.
  3. Whitespace in excluded tool names (minor). NewCeiling trims whitespace around excluded tool names (ceiling.go:36), but defDisallowsTool matches exactly. For mcp__github__ merge, the broker excludes the tool and the harness doesn't. The broker is the stricter side, but the agreement test doesn't cover it.
  4. The ceiling string is ambiguous (minor). Ceiling.String (ceiling.go:109) escapes nothing. Exclusions come from definition files, so a ,, a ;, or " except " makes the canonical form recorded in DecisionRecord.Ceiling ambiguous.
  5. Nits:
    • isGatewayServerName's doc says the rule rules out prefix clashes, but leading and trailing underscores still allow them: git and git_ both produce mcp__git___x.
    • The full ceiling string goes into every decision record and every refusal sent to the caller. It has no size limit, and it shows the child its parent's exclusion list.
    • effectiveCeilingLocked runs on every re-registration, and the result is discarded (agents.go:148).

Missing tests

  • No end-to-end test reaches a check 7 refusal. The harness drops the tool first, so #2851's "refused before any token is issued" is proven only by core unit tests.
  • The agreement test (internal/app/defgatewaytools_test.go:83-91) re-implements the broker's allow logic instead of calling Ceiling.allows/checkCeiling. Both sides also go through agentdef.Parse, despite the comment about "their own parsers".
  • No cases for:
    • tools containing . or __, through Validate, the ceiling, and the loader;
    • mixed-case names;
    • an integration case where the child's definition grants a server its parent lacks (only the property test covers this).

- A gateway call is refused unless the gateway routes it to the tool's own
  backend, so the harness and the broker always mean the same server.
- Ceilings match tool names exactly, as the harness does; records quote
  names holding a separator; a refusal no longer shows the ceiling.
- A built-in definition that sets tool fields fails to load instead of
  having them ignored.
- An effective ceiling is computed only for a new instance.
- Shortcut markers for restart recomputation (#2563) and reported
  definitions (#2551).
- The agreement test uses the broker's own check and covers built-ins and
  the main agent as parent; new cases for dotted, mixed-case, and
  ambiguous names, and a child under an empty ceiling.
- Docs: the server list the limit resolves against until #2533, whole-server
  entries, no backfill while state is in memory, the tool-naming refusal,
  unlimited listings until #2729, and the operator row's accuracy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
rdimitrov and others added 7 commits November 21, 2026 20:08
A helper that moved to its root's reopened broker session lazily, after
the reopen's own move failed, had no delegation reported there, so its
gateway calls were refused until it was resumed. The credential holder now
reports a helper's current delegation into each broker session it moves
to, after the delegations its delegating run descends from, before the
move is stored, so a failed report leaves the helper to move again. A
delegation set while a move is in flight is reported to the new session
too. The reopen no longer re-reports the whole delegation history.

The broker also:
- checks the owner of a delegating root run it has not seen against the
  session's owner, so one inconsistent report cannot fix the wrong owner;
- rebuilds a delegating run whose record was forgotten at the cap from its
  kept delegation, as AuthorizeCall does.

The design defines the open delegations a reopen reports, and the
in-memory record cap is marked as a shortcut.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
main now refuses the identity broker with a workspace on the process's
filesystem (#2875), so the delegation tests run file-less. Parallel
branches and API-created teams need a workspace, which the broker then
gets only through Kubernetes execution, so their end-to-end cases are
dropped; they report delegations through the same path the remaining
tests drive.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings in main, whose identity broker refuses a workspace on the process's
filesystem (#2875). Named definitions run only in sessions with a
workspace, so the named-subagent end-to-end test runs on the Redis
filesystem, and the named team member, which needs teams and so Kubernetes
execution, is tested through the member factory instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A team member without a filesystem skipped its agent definition entirely,
so it got every server-global MCP tool and every gateway tool, including
ones its definition excludes, and registered with the identity broker as
the built-in member, so the broker allowed them too. With the broker on,
file-less is the only setup outside Kubernetes execution (#2875).

A file-less member that names a definition now gets the file-less core
tools its definition does not exclude, its definition's own MCP servers
instead of the server-global ones and CallMcpWithQuery, and its servers'
gateway tools, and reports the definition, so the broker checks the same
limit. The rest of the definition stays file-oriented and is not applied.

The named team member end-to-end test runs again, file-less.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rdimitrov

Copy link
Copy Markdown
Member Author

Thanks, this was thorough. Point by point; fixes are in 29b94ce, plus aa312f5 for a related gap described at the end.

Design and ticket gaps

  1. Server list. Agreed the doc overstated it. The code stays as is, and mcp-authorization.md now says that until Configure the embedded gateway's authorization server as AS-2 #2533 builds the gateway from the MCP configuration, the broker resolves against its gateway entry's servers, which production leaves empty, so every gateway call is refused at check 6 first.
  2. Two server lists. There is one list. ib.gatewayServers feeds both the identity broker's loader and the MCP broker's GatewayCalls.Servers (internal/app/build.go), and a session tool is a helper gateway tool only if its backend is in that list (gatewayRoute). So defGatewayTools can only pick tools of servers the broker resolved against. I added a comment where the list is wired. The remaining gap was the name each side uses for a server, which is point 13, now enforced.
  3. Restart widening. Agreed, and it had no marker. Added a shortcut on effectiveCeilingLocked, removed by Durable broker state and recovery #2563, since durable state is what keeps each effective ceiling and its resolution inputs. While state is in memory, a restart also drops every registration, so the widening needs both a restart and a longer server list in the new process.
  4. Done-when items.
  5. Sign-off. Fair. The decision on Per-agent tool limit, checked by the broker #2842 is a proposal, and I've asked for the author's sign-off there before this merges.
  6. Decision text vs code.
    • The loader parses each mcp__<server>__<tool> exclusion once, at resolution. Calls are never parsed. The doc now says so; "nothing has to parse" in the decision referred to calls.
    • Reworded mcp-authorization.md and the implementation.md work breakdown. A server-wide entry permits the server's tools as they are when each call is checked, so a tool added later is allowed unless excluded by name, as the harness behaves.
  7. Built-ins. A built-in that sets tools, disallowedTools, or mcpServers now fails to load, with a test, instead of having them ignored.
  8. Tool naming. It is now stated as the gateway's contract: Gateway.Route's doc says the server must be the backend and the tool must be <server>.<tool>. An external gateway (External gateway: Gateway implementation, operator setup, and end-to-end test #2812) maps its names to that form. Added the INVALID_ARGUMENT row to the step (6) failure table, and a sentence on the request form.
  9. Listings. Right. Until List gateway tools with a broker-issued token #2729, listings use the MCP broker's own sign-in and never reach AuthorizeCall. The "Tool discovery" paragraph now says so, and that the harness gives a helper only its definition's gateway tools from that listing. The only agent that sees the full listing is the main agent, whose built-in ceiling grants every server.
  10. Tickets.
  11. Branch hygiene. Resolved: main is now merged into feat/run-delegations and that into this branch, so fix(app): keep a team member's MCP tools within its definition's exclusions #2939's change is in, with the member path appending the gateway tools to registered. I merged rather than rebased, so nothing was force-pushed. I'll check that "Closes Per-agent tool limit, checked by the broker #2842" links after this retargets to main.
  12. Operator docs. The row now:
    • says a server counts only when named by reference;
    • gives the mcp__<server>__<tool> form;
    • says inline entries and tools add no gateway tools;
    • says the chart doesn't configure a gateway yet, so helpers get no gateway tools for now.

Correctness

  1. Server names. The MCP broker now refuses a gateway call if Route names a server other than the tool's backend, before anything is authorized, with a test. GatewayServer()'s doc says it's the backend, and why that is the server the broker checks.
  2. Reported definition. Added a Full definition loader and registration rules #2551 shortcut on check 7: a root reporting system/main gets every server, and a child reporting a built-in gets its parent's whole ceiling.
  3. Whitespace. NewCeiling now keeps tool names exactly, as the harness does. In practice agentdef drops an entry like mcp__github__ merge before either side sees it. The agreement test has that case, alongside mixed case and dotted names.
  4. Record string. A tool name with anything other than letters, digits, _, -, or . is now quoted as a Go string, with a test.
  5. Nits.
    • Underscores: corrected isGatewayServerName's doc. The MCP configuration allows a trailing underscore, so the broker accepts it too. mcp__git___x is then ambiguous, and the loader excludes it from both servers, so it only narrows. A loader test covers it.
    • Ceiling in refusals: the refusal no longer shows the ceiling. Only the decision record names it, so a child no longer sees its parent's exclusions. The record's size is bounded by the definition file.
    • Recomputing on re-registration: the effective ceiling is now computed only for a new instance.

Missing tests

  • End-to-end check 7 refusal: not reachable through the harness by design, because the harness drops the tool first. Check 7 refusals are covered at AuthorizeCall with the real broker, counting that no exchange or redemption happens. The new route-mismatch test covers the MCP broker side.
  • Re-implemented allow logic: the agreement test now calls Ceiling.Allows, and its comment no longer claims separate parsers.
  • New cases:
    • tools with . and __ through Validate and the ceiling (TestAuthorizeCallSplitsOnlyTheServerPrefix), and through the loader;
    • mixed-case server prefixes, refused, and tool names, matched exactly;
    • a child whose definition grants github under a parent with an empty ceiling, refused (TestAuthorizeCallChildCannotGainAServerItsParentLacks).

Also changed since

  • File-less team members kept to their definition. feat(identitybroker): start the broker from operator configuration and keys #2875 on main refuses the broker with a workspace on the process's filesystem, so without Kubernetes execution its sessions are file-less. A file-less team member used to skip its agent definition entirely: it got every server-global MCP tool and every gateway tool, and it registered as system/member, so the broker allowed a tool its definition excludes. Now it gets the file-less core tools its definition doesn't exclude, its definition's own MCP servers in place of the server-global ones and CallMcpWithQuery, and its servers' gateway tools. It also reports the definition, so check 7 applies the same limit. The rest of the definition (prompt, model, hooks) still isn't applied without a filesystem. A file-less subagent already refuses a named definition.
  • End-to-end tests after feat(identitybroker): start the broker from operator configuration and keys #2875. The named-subagent test runs on the Redis filesystem, the one workspace the broker allows offline. The named team-member test runs file-less and now covers the case above. The member path with a filesystem, which needs Kubernetes execution, is covered by an app-level test on the real member factory.

Base automatically changed from feat/run-delegations to main November 23, 2026 12:19
# Conflicts:
#	cmd/mecak8s/identity_broker_delegations_test.go
#	cmd/mecak8s/identity_broker_harness_test.go
#	cmd/mecak8s/identity_broker_helpers_test.go
#	internal/identitybroker/authorize.go
#	internal/identitybroker/service.go
jhrozek and others added 7 commits November 23, 2026 13:43
retainHarnessGeneration returns a nil close when the harness instructions
are not generation-backed. The file-less member path called it unguarded,
so closing a defined member with its own MCP server panicked, and a failed
provider lookup did the same. Guard both, as the file-ful path does.

Co-Authored-By: mecatl <[email protected]>
…member

The file-less defined member catalog only filtered core tools by the
definition's disallowedTools, so a definition limited to a few tools still
got WebFetch, WebSearch and every memory tool. Scope the file-less core and
memory tools through scopedToolNamesMode, as the member with a filesystem
does. MCP and gateway tools keep following the definition's servers and
exclusions.

Co-Authored-By: mecatl <[email protected]>
Load a definition from files through the real broker path, with the
calendar server and one excluded tool, and register a helper running it.
Its call to the excluded tool and to a server it does not reference are
refused before any ID-JAG exchange, and its call to the server's other
tool passes the ceiling check.

Co-Authored-By: mecatl <[email protected]>
- Log filesystem tools named in a definition's `tools` at Debug instead of
  Warn "unknown tool": they do not exist without a filesystem. Genuinely
  unknown names still warn. Add the member name to the log, as the
  file-ful path does.
- Mention the `tools` allowlist in the buildMemberEngine comments.
- Reword the no-filesystem docs so disallowedTools is not described as
  limited to core and memory tools, and name the tools `tools` limits.
- Drop an always-true assertion and fix a stale definition description in
  the file-less member tests.

Co-Authored-By: mecatl <[email protected]>
@jhrozek jhrozek mentioned this pull request Nov 23, 2026
6 of 14 tasks

@jhrozek jhrozek 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.

Leaving this as a comment for now. The follow-ups are in #2956, which is stacked on this branch. Please merge it into feat/agent-tool-limit (or cherry-pick it) before this lands, because it fixes a panic this PR adds; I'll approve once it's in. I found no way for an agent to get a call outside its ceiling: the <server>.<tool> split, check order, the empty ceiling, intersection with the parent, and keeping the ceiling across re-registration all hold.

In #2956

  • Panic when a file-less team member closes. retainHarnessGeneration returns a nil close function when the harness instructions aren't generation-backed. The new close at build.go:8562 calls generationClose() without a check, so a file-less member whose definition has inline MCP servers panics on teardown. The file-ful path checks for nil at :8774.
  • The tools allowlist on file-less members. newNoFSDefinedMemberCatalog applied only disallowedTools, so a definition with tools: [Read] still got WebFetch, WebSearch, and the memory tools. Its comment said the definition narrows the member "the same way either way". #2956 scopes core tools with scopedToolNamesMode, as the file-ful path does. Drop that commit if you'd rather keep that narrowing for later.
  • Check 7 had no test with real definitions. The end-to-end tests never reach the refusal, because the harness hides the excluded tool first, so removing check 7 broke no test. #2956 adds an internal/app test that loads a definition from disk and calls AuthorizeCall. It also adds a test that the ceiling survives re-registration in a reopened broker session.
  • Smaller items. Ceiling.String() is now computed once instead of on every call. mcp-authorization.md:9 no longer says "and their tools". The tools.md sentence now says what each field does.

For you to change: the PR description's API compatibility section

"No deployment sees a difference today" isn't quite right. File-less team members that name a definition change whether the broker is on or off: they lose the server-wide MCP tools and CallMcpWithQuery, and they now connect their definition's inline servers. With the broker on, a member whose definition the broker didn't load (one not from --agents-dir) is now refused at registration and doesn't start; before, it ran as system/member. Nothing changes on the wire, so "no wire change" stands, but please name these two behavior changes there and in the release notes.

Not blocking

  • A tools/list through AuthorizeCall has no test; only checkCeiling is tested directly.
  • TestNewRefusesAnInvalidGateway covers dots, __, and -, but not non-ASCII letters or spaces.

@rdimitrov

rdimitrov commented Nov 23, 2026 •

Copy link
Copy Markdown
Member Author

Thanks. #2956 is in (fast-forwarded, so its commits are here as you wrote them). I checked each fix:

  • retainHarnessGeneration does return a nil close when the instructions aren't generation-backed, so the panic was real.
  • The cached String() is set on every path that builds a Ceiling (NewCeiling and intersect); the zero value still prints none.

The internal/identitybroker, internal/app, and cmd/mecak8s broker tests pass, and lint is clean.

PR description: the API compatibility section now lists the behavior changes for the release notes:

  • File-less named members keep to their definition with the broker on or off: no server-wide MCP tools or CallMcpWithQuery, their own servers including inline ones, and their tools and disallowedTools.
  • With the broker on, they register under their definition, so a member whose definition the broker didn't load is refused and doesn't start.

Not blocking: both added. TestNewRefusesAnInvalidGateway has a non-ASCII row (b8bc9cc); spaces were already covered by git hub. TestAuthorizeCallListingFollowsTheCeilingsServers sends tools/list through AuthorizeCall: allowed on a server the effective ceiling grants, even with excluded tools, and refused under an empty ceiling (aaa0bc1). It fails if the list case stops checking the server. Nothing in production sends a listing to AuthorizeCall until #2729.

@jhrozek jhrozek 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.

Approving. #2956 is in, the API compatibility section now names the behavior changes, and the two extra tests look good. Thanks.

@jhrozek
jhrozek merged commit f50bb37 into main Nov 23, 2026
50 checks passed
@jhrozek
jhrozek deleted the feat/agent-tool-limit branch November 23, 2026 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Per-agent tool limit, checked by the broker

3 participants