Skip to main content

mcp-trace-inspector

CI License: MIT

mcp-trace-inspector is a small, local-first stdio MCP server for querying JSONL OpenTelemetry spans emitted by agent runs. It exposes focused queries for run summaries, tool failures, approvals, activity, and comparisons instead of requiring an application-specific dashboard.

It pairs with agent-harness, but the reader is format-simple: any JSONL of OTel-shaped spans works. The project's concrete origin was a shell-boundary regression: the harness blocked cat ../outside.txt, but the old trace recorded only that run_shell was called, not the returned diagnostic. mcp-trace-inspector and the harness now preserve and query that bounded error.

AI-native use cases

Question during an agent run MCP tool Evidence returned
"Why did yesterday's run stall?" list_runs → slowest_spans Run IDs and the longest model or tool spans.
"Did the agent act after I denied the write?" approval_log → span_tree The recorded decision and subsequent execution path.
"How many model tokens did this run use?" token_usage → span_tree Run-level usage totals and the span tree for context.
"Which tool is failing or timing out?" failure_report / tool_stats Redacted diagnostics, error rates, denials, and p95 latency.
"Who/what was allowed to act?" security_audit Caller, tenant, server provenance, risk, and missing-evidence findings.
"What is happening in the run right now?" recent_activity Cursor-based polling of newly written spans.
"Did this model/version regress?" compare_runs Cost, latency, tokens, tool calls, and failure deltas.

The tools read stored traces and can poll files being written, but they do not push events or infer intent from the final answer. Start with the installation and user guide, then see the real trace fixture and the tool descriptions for the query contract.

Install & run

uvx mcp-trace-inspector --trace-dir ./traces
# or, for local development:
git clone https://github.com/abhishekash/mcp-trace-inspector
cd mcp-trace-inspector && uv pip install -e .
mcp-trace-inspector --trace-dir ./traces

Client configuration

Claude Desktop (claude_desktop_config.json):

{
  "mcpServers": {
    "agent-traces": {
      "command": "uvx",
      "args": ["mcp-trace-inspector", "--trace-dir", "/path/to/traces"]
    }
  }
}

pi (~/.pi/agent/settings.json):

{
  "mcpServers": {
    "agent-traces": {
      "command": "uvx",
      "args": ["mcp-trace-inspector", "--trace-dir", "/path/to/traces"]
    }
  }
}

agent-harness (mounted as gated tools):

harness run "Why was my last run slow?" --mcp "uvx mcp-trace-inspector --trace-dir ./traces"

Tools

Tool Use it when
list_runs Starting out — recent runs with task, model, duration, cost, decision counts
run_summary One run at a glance (accepts trace-id prefix)
span_tree "What did the agent actually do?" — nested shape of the run
slowest_spans "Why was it slow?" — top-k spans by duration
approval_log HITL audit — every approve/deny/edit, who decided, and the rationale
token_usage Cost questions — aggregated across runs or per-run
search_spans Find spans by tool name, file path, "denied", …
failure_report Find actionable, bounded, redacted errors and failed tool calls.
tool_stats Rank tools by volume, error rate, denials, and latency.
security_audit Audit caller identity, tenant, server provenance, risk, and approval evidence.
recent_activity Poll new spans with a cursor while a run is active.
compare_runs Compare selected traces for regressions across models or versions.

Tool descriptions are written as prompts (when-to-use, not just what-it-does) — descriptions are the interface for agent-called tools.

Example session (real fixture trace)

> list_runs
[{ "trace_id": "f920798dd255…", "task": "Summarize the workspace's notes…",
   "tool_calls": 4, "human_decisions": 2, "stopped_reason": "completed" }]

> approval_log
[{ "tool": "write_file", "decision": "approve", "approver": "auto", … },
 { "tool": "run_shell",  "decision": "approve", "approver": "auto", … }]

Design

traces/*.jsonl ──▶ mcp_trace.core (pure query functions, zero deps)
                          │
                   mcp_trace.server (thin MCPServer adapter, mcp 2.x)
                          │
                    stdio (NDJSON JSON-RPC)
  • core/server split: all logic is pure functions over parsed spans; the MCP layer only parses args and JSON-encodes results. Tests hit both layers.
  • trace_id prefixes: agents fumble full 32-char hex ids; every tool accepts prefixes.
  • bounded output: diagnostics are truncated and obvious credentials are redacted before query results leave the server.
  • honest cost totals: token_usage returns cost_known: false and a null cost when any producer marks pricing as unavailable; unknown pricing is never presented as $0.
  • cursor polling: recent_activity makes the snapshot reader useful while a run is still writing spans.
  • The demo fixture (examples/example_trace.jsonl) is a real agent-harness run, not hand-written.

Honest limitations

  • stdio transport only (Streamable HTTP plus authenticated remote access is the next transport boundary)
  • live polling re-reads snapshots; it is not a push subscription
  • security audit can only report identity/provenance that the trace producer records
  • read-only tools; trace mutation (annotations) is roadmap
  • The Python query and server modules are available as mcp_trace; older import and command aliases remain for existing clients.

License

MIT

Metadata

Release files for mcp-trace-inspector 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcp-trace-inspector 0.3.0
File Size Uploaded
mcp_trace_inspector-0.3.0.tar.gz 20.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mcp-trace-inspector 0.3.0
File Interpreter ABI Platform
mcp_trace_inspector-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 35.5 kB

Release files / mcp_trace_inspector-0.3.0.tar.gz

Download URL mcp_trace_inspector-0.3.0.tar.gz
Size 20.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c0ff0a816137cae4a3388b0945fc718be48f16f078ed4c297f067df8e62cdeac
BLAKE2b-256 checksum
How to use checksums
a0219b07bb4cf6c6dc842b2d0fbbe3851402ab4eb0384a2e527cf4670d913889
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

Release files / mcp_trace_inspector-0.3.0-py3-none-any.whl

Download URL mcp_trace_inspector-0.3.0-py3-none-any.whl
Size 14.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
932af95f964d803dd06369cf131cf57706d9c7b41753835a4cee74734f7735bd
BLAKE2b-256 checksum
How to use checksums
a613d55b627199e840f18965900c4b84098244c5e37e83d8efec9688f57af5ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

Release history Release notifications | RSS feed

0.3.1

2 release files

This release

0.3.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page