cleandataengineering.aiAgent Harness, drawn simply
You are here: End to end › Checks › 2 · Before the model › allowed tools only

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.

Open: 11before loopopen ›Open: 22before modelopen ›Open: 33after modelopen ›Open: 44before toolopen ›Open: 55the toolopen ›Open: 66after toolopen ›Open: 77after loopopen ›Open: 88before replyopen ›It readsthe scopes in Rohan's token andeach tool's required scopeallowed tools onlyrule · harnesspassCarries onfailIf it failsthe tool is never offeredWHERE IN THE CODE: GatedTools.list_tools() · H tools/__init__.py:106
The strip at the top shows every check point where this check runs, in dark.

How we took care of it.

  1. Before the first trip, ask the claims system for its tools (MCP tools/list).
  2. Keep only tools whose required scope is in the token.
  3. issue_payout needs a staff scope, so it is never shown, and the model can't ask for what it can't see.
  4. The claims system checks the token again on its side (check point 5).
It readsthe scopes in Rohan's token and each tool's required scope
Kindrule
Provided byharness
If it failsthe tool is never offered
Where in the codeGatedTools.list_tools() · H tools/__init__.py:106
Runs at2 · 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)