SpanHound

io.github.abhishekash由 GitHub 帳號 abhishekash 發布v0.6.1更新於 Oct 29, 2026

Capture local agent traces and inspect failures, approvals, and run comparisons.

概覽

AI 產生的概覽

SpanHound 擷取本機 AI 代理追蹤,並透過唯讀 MCP 工具檢視失敗、審批、token 用量與執行比較。

可以做什麼
  • 列出並彙總已擷取的執行,包含任務、模型、時長、成本與決策次數,並檢視某次執行的巢狀 span 樹。
  • 排查效能與失敗:最慢 span、經截斷與去識別化的錯誤報告、依錯誤率/拒絕/延遲排序的工具統計,以及依工具名稱或路徑搜尋 span。
  • 稽核人工審批與安全證據:含審批者與理由的審批日誌,以及呼叫方、租戶與來源相關發現。
  • 追蹤成本與回歸:跨執行或單次執行的 token 用量,以及針對不同模型或版本的選定追蹤比較。
  • 在執行仍在寫入時,以游標輪詢新產生的 span。
適用情境
適合想透過 MCP 用戶端了解本機代理執行究竟做了什麼、又不想架設追蹤後端的情況。可用於排查卡頓與失敗、確認代理在被拒絕後是否仍執行動作,以及比較執行以找出回歸。
執行需求
透過 uvx 以 stdio 在本機執行,首次執行會安裝 Python 相依套件。需要一個存放 JSONL span 或已儲存 OTLP JSON 匯出的資料夾,或是在與代理相同的 Python 環境中安裝選用的自動埋點套件。OTLP 接收器監聽本機回環位址。未宣告需要帳號或 API 金鑰。
安裝前請注意
追蹤檔案在本機讀取,但工具回傳的證據會傳送給所連線的 MCP 用戶端。診斷資訊會被截斷且明顯憑證會被去識別化,但追蹤中仍可能含有敏感提示詞、路徑或工具輸出。工具為唯讀;接收器在本機回環位址接受 OTLP,能存取該埠的程式都可寫入追蹤檔案。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 SpanHound,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

[SpanHound logo]

SpanHound

[CI] [PyPI] [Downloads] [GitHub release] [GitHub stars] [MCP Registry] [Glama MCP server] [License: MIT] [Python 3.11+]

Capture local agent traces. Ask your MCP client what happened. SpanHound (formerly mcp-trace-inspector) captures supported Python agent calls, receives OpenTelemetry over local OTLP/HTTP, and exposes read-only MCP tools for failures, approval decisions, token usage, and run comparisons. It reads JSONL spans and OTLP JSON exports as described in the user guide, including traces from agent-harness.

[Animated demo: a blocked tool call becomes an inspectable trace]

Demo: Watch the full 48-second video · Read the reproducible story. This is a scripted regression trace, not a live-model benchmark.

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. SpanHound and the harness now preserve and query that bounded error.

Try it in one command

bash
uvx spanhound demo
text
SpanHound demo — recorded agent failureTool: run_shellFailure: error: shell path escapes workspace root: '../outside.txt'Approval: approve (auto)Trace: 563e779ee8fa2d7069fc63ed2cf9c8ec (6 spans)

The demo shows a recorded run_shell failure and its approval evidence from a bundled scripted regression trace. It needs no clone, account, trace backend, or MCP client. To inspect your own traces, point SpanHound at a directory of JSONL spans or saved OTLP JSON exports:

bash
uvx spanhound --trace-dir /path/to/traces --check

--check prints the runs it found and exits. Connect an MCP client with the configuration below to ask questions about those runs.

Explore the repository fixtures

bash
git clone https://github.com/abhishekash/spanhound.gitcd spanhounduvx --from . spanhound --trace-dir examples --check

--check also reports a missing directory or malformed complete JSONL or OTLP JSON record.

To try an OTLP JSON export, run the same command with --trace-dir tests/fixtures. The sample export includes a model call, token usage, a tool call, and an exception.

Capture your own traces

For a Python agent, install SpanHound's optional auto instrumentation in the same environment as the agent, then run it through SpanHound:

bash
python -m pip install 'spanhound[auto]'spanhound run --trace-dir ./traces -- python agent.py

The command starts and stops a local receiver, configures OTLP export, and captures supported library calls without changes to agent.py. The optional package includes instrumentation for OpenAI, Anthropic, OpenAI Agents, HTTPX, and Requests. It reports when no spans were produced. Your Python agent and SpanHound must share one environment; for a uv project, use uv add 'spanhound[auto]' and uv run spanhound run -- python agent.py. See the Python capture guide.

For other runtimes, or agents that already export OpenTelemetry traces, start the receiver in one terminal:

bash
uvx spanhound collect --trace-dir ./traces

Point an agent that already uses an OpenTelemetry trace exporter at the receiver, then run the agent:

bash
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://127.0.0.1:4318/v1/tracesexport OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=http/protobuf# Start your instrumented agent here.

SpanHound stores each accepted OTLP/HTTP trace request as a local JSON file. Run uvx spanhound --trace-dir ./traces --check to see the captured runs, then connect your MCP client to that folder. The receiver accepts OTLP/HTTP JSON or protobuf on loopback; it does not add instrumentation to an agent. See the capture guide for limits and privacy.

Where it fits

For a live terminal and browser view of local Codex/Claude Code sessions and received OTLP telemetry, try Agent Observatory. SpanHound provides trace investigation through MCP using JSONL and OTLP JSON files.

Use this when you want a local trace view through MCP without setting up a trace backend. Capture supported Python library calls in one command, receive OTLP/HTTP from another runtime, or read the supported JSONL or OTLP JSON formats. Focused queries include recorded approval decisions, bounded failure diagnostics, and run comparisons.

MCP Agent Trace Inspector records steps into a local SQLite database and provides a dashboard and exports. SpanHound auto-instruments supported Python libraries or receives OTLP/HTTP traces, then queries the captured files through MCP. It does not automatically trace arbitrary agent functions or approvals.

For traces stored in Jaeger, Tempo, or Traceloop, use a backend-connected tool such as OpenTelemetry MCP Server. For a trace UI, instrumentation, and evaluations, see Phoenix. SpanHound does not read backend-specific JSON exports.

AI-native use cases

Question during an agent runMCP toolEvidence returned
"Why did yesterday's run stall?"list_runs → slowest_spansRun IDs and the longest model or tool spans.
"Did the agent act after I denied the write?"approval_log → span_treeThe recorded decision and subsequent execution path.
"How many model tokens did this run use?"token_usage → span_treeRun-level usage totals and the span tree for context.
"Which tool is failing or timing out?"failure_report / tool_statsRedacted diagnostics, error rates, denials, and p95 latency.
"Who/what was allowed to act?"security_auditCaller, tenant, server provenance, risk, and missing-evidence findings.
"What is happening in the run right now?"recent_activityCursor-based polling of newly written spans.
"Did this model/version regress?"compare_runsCost, 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

bash
uvx spanhound --trace-dir ./traces# or, for local development:git clone https://github.com/abhishekash/spanhoundcd spanhounduvx --from . spanhound --trace-dir ./traces

For a desktop client that accepts MCP Bundles, download the .mcpb asset from the latest release and install the downloaded file in the client; the download link does not open a web page. In Claude Desktop, use Settings → Extensions → Advanced settings → Install Extension… and select the .mcpb file. The bundle asks you to choose a local trace folder. It uses UV to install its Python dependencies on first run. SpanHound reads the folder locally; the connected client receives the evidence returned by its MCP tools.

If you previously ran uvx mcp-trace-inspector, change that command to uvx spanhound to receive this release. The old PyPI distribution stays at 0.3.1; the new package retains its Python import paths and command aliases for clients that install spanhound explicitly.

Client configuration

Claude Desktop (claude_desktop_config.json):

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

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

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

agent-harness (mounted as gated tools):

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

Tools

ToolUse it when
list_runsStarting out — recent runs with task, model, duration, cost, decision counts
run_summaryOne 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_logHITL audit — every approve/deny/edit, who decided, and the rationale
token_usageCost questions — aggregated across runs or per-run
search_spansFind spans by tool name, file path, "denied", …
failure_reportFind actionable, bounded, redacted errors and failed tool calls.
tool_statsRank tools by volume, error rate, denials, and latency.
security_auditAudit caller identity, tenant, server provenance, risk, and approval evidence.
recent_activityPoll new spans with a cursor while a run is active.
compare_runsCompare 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": "f920798dd2558fcb84f9977736432a8b", "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 ──┐traces/*.json  ──┴─▶ mcp_trace.core (local query functions)                          │                   mcp_trace.server (MCP adapter)                          │                    stdio (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 model span lacks a cost or 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

  • MCP 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.

First-run feedback

Tell us what happened when you tried it: your MCP client or trace producer, the question you were trying to answer, and any missing evidence. Share a redacted excerpt when a file fails to load.

License

MIT

來源:README.md,提交 5991bda

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

3
  1. v0.6.1最新Oct 15, 2026
  2. v0.6.0Oct 13, 2026
  3. v0.4.1Oct 13, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分