Agent Harness Tutorial · End to end · Zoom level 3
How we take care of it: allowed tools only
allowed tools only catches tools his token doesn't allow.
How we took care of it.
- Before the first trip, ask the claims system for its tools (MCP tools/list).
- Keep only tools whose required scope is in the token.
- issue_payout needs a staff scope, so it is never shown, and the model can't ask for what it can't see.
- The claims system checks the token again on its side (check point 5).
| It reads | the scopes in Rohan's token and each tool's required scope |
| Kind | rule |
| Provided by | harness |
| If it fails | the tool is never offered |
| Where in the code | GatedTools.list_tools() · H tools/__init__.py:106 |
| Runs at | 2 · Before the model |
Real exampleRohan's model sees 8 tools; issue_payout is not among them.
More on this: Which tools it sees.
How it is done: the real code
Cut from the live repositories each time the site is built, so it always matches what runs.
async def list_tools(self, identity: Identity) -> ToolRegistry:
"""The action surface for this identity.
MCP permits `tools/list` to vary by the authorization presented, so a
scope-filtered surface is protocol-legal rather than a local invention.
"""
with tel.span("agent.tools.list") as span:
specs, rejected = await self._transport.advertised()
visible = tuple(
s for s in specs if not s.required_scope or identity.may(s.required_scope)
)
self.rejected = rejected
span.set_attribute("agent.tools.count", len(visible))
for offered in visible: # AACP-0026: a tool on the surface nobody calls
tel.counters.tools_offered.add(1, {"tool": offered.name})
span.set_attribute("agent.tools.rejected", len(rejected))
return ToolRegistry(tools=visible)