SpanHound is an open-source tool for capturing and inspecting local AI agent traces, formerly named mcp-trace-inspector. Its core purpose is to let developers query trace data generated during agent runs through an MCP client, including failure diagnosis, approval decisions, token usage, and run regression comparisons.
Main capabilities:
- Capture supported Python agent calls: through an optional auto-instrumentation package, capture calls to libraries such as OpenAI, Anthropic, OpenAI Agents, HTTPX, and Requests without modifying agent.py.
- Receive OTLP/HTTP traces: start a local receiver to accept OTLP/HTTP JSON or protobuf trace requests from other runtimes or agents that already use an OpenTelemetry exporter, and save each request as a local JSON file.
- Read JSONL and OTLP JSON files: support reading JSONL span files and saved OTLP JSON export files, including traces from agent-harness.
- Provide read-only query tools via MCP: expose MCP tools for querying failures, approval decisions, token usage, and run comparisons. Tool descriptions are written as prompts explaining when to use them.
- Support trace_id prefix queries: each tool accepts a trace_id prefix for ease of use by agents.
- Bounded output and credential redaction: diagnostic information is truncated, and obvious credentials are redacted before query results leave the server.
- Honest cost totals: when any model span lacks cost or marked pricing is unavailable, token_usage returns cost_known: false and null cost, and does not present unknown pricing as $0.
- Cursor polling: recent_activity can use a snapshot reader while a run is still writing spans.
Usage:
- Try it with one command: the demo uses a bundled scripted regression trace to show a recorded run_shell failure and its approval evidence, with no clone, account, tracing backend, or MCP client required.
- Inspect your own traces: point SpanHound at a directory containing JSONL spans or saved OTLP JSON exports, and use --check to print the runs found and exit.
- Capture Python Agent tracing: install the optional auto-instrumentation package in the agent's same environment, then run the agent through SpanHound. The command starts and stops a local receiver, configures OTLP export, and captures supported library calls. For uv projects, use uv add 'spanhound[auto]' and uv run spanhound run -- python agent.py.
- Receive OTLP traces from other runtimes: start the receiver in one terminal, point the agent that already uses an OpenTelemetry trace exporter at that receiver, then run the agent. Use uvx spanhound --trace-dir ./traces --check to view captured runs, then connect an MCP client to that folder.
- Desktop client: download the .mcpb asset from the latest release, and in Claude Desktop select the .mcpb file via Settings → Extensions → Advanced settings → Install extension…. The bundle will ask you to select a local trace folder, and the first run uses UV to install Python dependencies.
- Client configuration: configuration examples are provided for Claude Desktop, pi, and agent-harness.
When to use:
- Developers who want to view traces locally via MCP without setting up a tracing backend.
- Scenarios that need to inspect failure diagnostics, approval decisions, and token usage in agent runs.
- Scenarios that need regression comparison of agent runs.
- Agents that use supported Python libraries or already export OpenTelemetry traces.
Limitations:
- Only MCP stdio transport is supported; Streamable HTTP plus authenticated remote access is the next transport boundary.
- Live polling re-reads snapshots; it is not push subscription.
- Security auditing can only report the identity/origin information recorded by the trace producer.
- Tools are read-only; trace changes (annotations) are on the roadmap.
- It does not automatically trace arbitrary agent functions or approvals.
- It does not read backend-specific JSON exports (such as Jaeger, Tempo, Traceloop).
- The receiver only accepts OTLP/HTTP on loopback addresses and does not add instrumentation to agents.
- Python query and server modules are provided as mcp_trace; legacy imports and command aliases are retained for existing clients.
- The legacy PyPI distribution package stays at 0.3.1; the new package retains the Python import path and command aliases.
Demo notes: the demo is a scripted regression trace, not a live model benchmark. The demo fixture (examples/example_trace.jsonl) is a real agent-harness run, not handwritten.