Skip to content

Sessions started with a named agent definition get their servers' gateway tools #2938

Done

Description

@rdimitrov

Depends on: #2842 (PR #2937: the broker checks each agent's tool limit, and named-definition helpers get their servers' gateway tools)
Adds shortcut: the harness works out a named session's gateway tools from its definition again, rather than reading the ceiling the broker recorded; removed by #2548
Adds shortcut: a named session gets only a server's statically declared gateway tools, because listing goes through the MCP broker's sign-in (workspace enrollment), which it cannot use; removed by #2729

Problem

A session started with a named agent definition (agent_definition_name) gets no MCP gateway tools. Its main agent can't call a gateway server even when its definition's mcpServers references it, and the identity broker would allow the call.

This was deliberate when #2003 added these sessions: an agent-bound session never attaches to the MCP broker, so broker tools can't widen its catalog beyond what the definition allows. #2842 now gives that narrowing: the harness gives a named helper only the gateway tools of the servers its definition references, minus its disallowedTools, and the broker resolves the same ceiling and refuses any call outside it. So the main agent of an agent-bound session can get the same tools without widening past its definition.

Proposal

  • Attach the gateway tools. Give an agent-bound session the gateway-routed tools of its root's MCP broker attachment that its definition references, filtered by defGatewayTools as for named helpers. Do this before its authority is minted, so the authority, which comes from the catalog, stays within the definition.
  • No other broker routes. Other broker routes act as the session with its shared grant, so the session gets none, as helpers get none.
  • Only with the identity broker on. Gateway tools exist only then, so the broker checks every call against the same limit.
  • Rebuilds. Fork, Clear, and a live rebuild offer only the gateway tools the session's authority already allows. A lazy grant is still refused, since the session has no other broker tools to reach it, and a restart stays refused until Session-scoped agent identity: persist and enforce authority across all engine-rebuild paths #1796.
  • Helpers stay out of scope. An agent-bound root still starts no helpers (Subagent, Team), and API team members in such a session get no gateway tools (Implement session-scoped Agent Definitions #2003's exclusion; not planned).

Done when

  • The main agent of a session started with a named definition calls a gateway tool of a server its definition references, under its own identity, through the real AS-1, AS-2, and gateway (cmd/mecak8s end to end).
  • It doesn't get a tool its definition excludes or a server it doesn't reference.
  • Fork, Clear, and a live rebuild offer only the gateway tools the session's authority allows.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions