callTool yourself. The instrumented MCP client wraps your existing client and handles guard evaluation and telemetry automatically.
When you finish this page, MCP tool calls inside a run will be observed and guarded with minimal boilerplate.
Prerequisites
Establish a run first. The instrumented client readsrunId from run context (sync Python) or requires it explicitly (async Python).
Per-call wrapper
For one-off MCP calls with explicit metadata, usewithMcpToolCall:
What you’ll see
agent.mcp.called, agent.mcp.completed, or agent.mcp.failed events in the run timeline with server name, tool name, and guard evaluation results.
Sync vs async context (Python)
| Client | Run context | runId required? |
|---|---|---|
Apie (sync) | run_context sets contextvars | No — auto-read from context |
AsyncApie | No contextvars | Yes — pass explicitly in wrappers |
runId to with_mcp_tool_call and create_instrumented_mcp_client_async. See Python sync and async.
Proxy vs instrumented client
| Approach | When to use |
|---|---|
| MCP proxy | MCP host config (Cursor, Claude Desktop) — zero code |
| Instrumented client | Custom agent code calling MCP in-process |
Next steps
Production release gate
Pipeline with MCP CI/CD trigger.
Instrument tool calls
General tool instrumentation patterns.
