Skip to content

Per-agent tool limit, checked by the broker #2842

Closed

Description

@ChrisJBurns

Depends on: #2527 (registration records each instance's definition and parent)
Removes shortcut: helpers that run a named definition get no gateway tools (#2555)
Adds shortcut: the limit is a plain set check, not generated Cedar policy, and decision records name no policy revision, removed by #2849

Problem

The broker accepts every call's tool without checking it. The only limits on which tools an agent may call sit inside the agent host: the harness's delegation restrictions, and plan mode's filter based on the server's own read-only hints. A helper can call any tool its catalogue offers. Nothing outside the agent loop keeps an agent, or its children, to the tools its definition allows.

Implements

Scope

Decide before starting

  • Where does the broker get each gateway server's tool list to resolve definitions against? The design resolves against "registered MCP servers and their tools" but does not say where those come from.

Done when

  • The implementation.md bullets above pass. That includes the property tests showing a child's effective ceiling is within its definition's and its parent's, and the test that the deployer child of a read-only reviewer is denied merge.
  • A call outside the effective ceiling, or one whose evaluation errors, is refused as check 7's row says, before any token is issued.
  • Each decision record names the evaluated ceiling.
  • Live instances are backfilled as the "Authority work switched on" row says.

Activity

  1. ChrisJBurns commented on Nov 18, 2026

    @ChrisJBurns
    ContributorAuthor

    Design decision for this ticket: Where does the broker get each gateway server's tool list, to resolve an agent definition's limit into server/tool pairs? The design resolves at admission "against registered MCP servers and their tools" but does not say where those come from (for example, gateway entries list their tools).

    Where it goes: mcp-authorization.md: Definition-derived ceiling.

    Decide it when this ticket is picked up, and record the answer as a small design edit (reviewed by the design's author) before or with the ticket's first PR.

  2. self-assigned this
    on Nov 20, 2026
  3. rdimitrov commented on Nov 20, 2026

    @rdimitrov
    Member

    Decision for #2842, proposed: what the broker resolves a definition's limit against

    The open question: the design resolves a definition's Tools, DisallowedTools, and MCPServers "against registered MCP servers and their tools", but doesn't say where those come from.

    Proposal: resolve against the gateway servers in the operator's MCP configuration, without each server's tool list.

    • The registered servers are the servers in the operator's MCP configuration (mcp.servers in settings.yaml), the same list mecak8s's MCP client routes through the gateway. The loader reads it when it loads definitions, so the same definition and configuration always produce the same limit.
    • A server-wide entry. The harness gives a definition every tool of each server its MCPServers names, minus the exact names its DisallowedTools lists (internal/app/agentdefs.go). Tools can't select MCP tools today. The broker keeps the same meaning: each referenced server becomes an entry "every tool of this server, except these names". Each call's exact server and tool are checked against it, by comparing the tool's catalog name, so nothing has to parse mcp__<server>__<tool>.
    • No match grants nothing. An inline server, or a reference to a server that isn't configured, resolves to nothing, so a call to it is refused. No MCPServers means no gateway tools, as today.
    • Built-in definitions go through the same resolution. Their built-in fields name every configured server: system/main gets them all, as the main conversation does today. For system/explorer, system/branch, and system/member, the parent's limit then narrows that at registration, which keeps what Helper agents: their own registered identity and broker MCP tools #2555 does today.

    Why not resolve against tool lists:

    • The broker can't list tools when it loads definitions. Listing a server's tools needs a user's grant and their provider credential ("Tool discovery" in mcp-authorization.md; List gateway tools with a broker-issued token #2729), and nobody is signed in at broker startup. The list can also differ per user.
    • Resolving at each call against the session's listing would make the limit depend on who is signed in and when. That breaks "the same admitted inputs produce the same ceiling".
    • The tools lists in the configuration are optional and exist only for some OAuth backends. Requiring them would leave every other server with no grantable tools.

    What changes in behavior: a tool the gateway adds later is inside the limit of every definition that references its server, unless the definition excludes it by name. That's what the harness does today. A definition that wants a fixed set keeps excluding by name until Tools can select MCP tools.

    Later: #2849's generated Cedar policy can express a server-wide entry with exclusions directly (resource in Server::"github", minus the excluded tools), so this doesn't need re-resolving then. Adding a server to the configuration changes the limit only for instances registered after the broker reloads it; registered instances keep their stored limit, as the design requires.

    Where it goes: a paragraph under Definition-derived ceiling, after the sentence on resolution: "Registered MCP servers are the servers in the operator's MCP configuration. A referenced server resolves to all of its tools except those DisallowedTools names, kept as one server-wide entry that each call's exact server and tool are checked against. Resolution needs no tool list, since listing tools needs a user's grant and can differ per user."

    If this looks right, I'll record it as a small design edit with the ticket's first PR.

  4. rdimitrov commented on Nov 21, 2026

    @rdimitrov
    Member

    Sign-off needed on the decision above before #2937 merges, plus three clarifications from review.

    1. Server list. The decision says the ceiling resolves against the operator's MCP configuration. That is the target state after Configure the embedded gateway's authorization server as AS-2 #2533. Until then, the broker resolves against its gateway entry's servers, which production leaves empty, so every gateway call is refused at check 6 first. The MCP broker routes helper tools through the gateway from the same list, so the harness and the broker can't diverge.
    2. Parsing. "Nothing has to parse mcp__<server>__<tool>" holds for calls. The loader does parse each exclusion once, at resolution, to find its server. A call is checked by its exact server and tool.
    3. Backfill. The "Authority work switched on" row's backfill doesn't apply while broker state is in memory: no instance outlives the broker that registered it. Revisit with Broker over gRPC, authenticated as the mecak8s workload #2559 and Durable broker state and recovery #2563. agent-definitions.md now records this.

    Also: 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. The design's "server/tool pairs" wording is reconciled in mcp-authorization.md and implementation.md.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions