Agent Harness Tutorial · Tech stack
L3 · Tool layer
Actions through typed tools, checked before they run. Family: Act · one turn, in order.
Why our choiceMCP is an open protocol and the only path to the claims system; our _meta keys carry scope, side effect and idempotency.
| Option | Where from | Verdict | Why |
|---|---|---|---|
| MCP Python SDK | ours | ✓ chosen | client + claims server |
| jsonschema | ours | ✓ chosen | arguments checked |
| Our gating, keys, size caps | ours | ✓ chosen | |
| MCP servers on Container Apps | Azure | ✓ used | |
| APIM in front of MCP | Azure | ◐ planned | tier 10 |
| Foundry tools | Azure | · considered | not picked |
| MCP Python SDK | open source | ✓ used | open protocol |
| FastMCP | open source | · considered |
How it works inside the harness: Tool call.
Compared: How does the agent call tools?
| Option | From | Verdict | What it is | Process boundary | Per-tool metadata | Auth on every call | Verdict reason |
|---|---|---|---|---|---|---|---|
| MCP Python SDK (mcp) | open source | chosen | official MCP client and server | yes: its own server | _meta: side effect, scope | bearer token checked again | MCP is the only path |
| FastMCP | open source | alternative | higher-level MCP server library | yes | yes | yes, via its auth | listed beside the official SDK |
| Function tools in process | open source | rejected | Python functions given to model | no: same process | only what we add | inherits the agent's rights | no far-end checks |
| OpenAPI / REST tools | open source | rejected | HTTP API described by OpenAPI | yes | no standard place | yes | not shaped by intent |
| APIM REST-as-MCP | Azure | rejected | APIM exposes REST as MCP | yes | no | at the gateway | wraps REST, not intent |
| Foundry tools | Azure | only on Foundry | tools in Foundry Agent Service | Foundry runs them | Foundry's own | Foundry connections | only if the loop moves there |
DecisionTools are dedicated MCP servers built with the official MCP Python SDK, each tool declaring its side effect and required scope, and the far end checks the token again. We would put APIM in front as the MCP front door, but never use REST-as-MCP for agent-facing tools.
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 invoke(
self,
name: str,
arguments: dict[str, object],
*,
caller: Identity,
idempotency_key: IdempotencyKey | None = None,
) -> ToolResult:
"""Both MCP failure channels, kept apart — and the caller carried with the call.
The session travels as request metadata, not as an argument: the model
writes the arguments, and whose session this is must never be something
the model can say.
A protocol error (unknown tool, malformed request) raises and surfaces
here; an execution error comes back as an ordinary result with
`is_error` set. An agent that handles one and not the other looks
healthy until production.
"""
try:
# MCP's `_meta` is an open object; the SDK's TypedDict names only the
# progress token. The cast states that gap rather than hiding it.
fields: dict[str, object] = {SESSION_META: await self._session(caller)}
if caller.grant is not None:
fields[APPROVAL_META] = caller.grant
if idempotency_key is not None:
fields[IDEMPOTENCY_META] = idempotency_key.value
meta = cast(RequestParamsMeta, fields)
raw = await self._client.call_tool(name, arguments, meta=meta)
except Exception as exc:
# Into the model's context, so scrubbed first: a far end's error can
# quote the token or key it refused (AHC-0035, F-074). The kind of
# failure stays, because the model chooses its next step by it.
said = f"{type(exc).__name__}: {redact(str(exc))}"