Spanlens

io.github.spanlens由 GitHub 帳號 spanlens 發布v0.3.0更新於 Oct 27, 2026

Query Spanlens LLM observability from Cursor, Claude Desktop, or Continue via MCP.

概覽

AI 產生的概覽

Spanlens MCP 伺服器讓助理查詢你的 Spanlens LLM 可觀測性工作區,取得花費、請求、追蹤、異常與節省建議。

可以做什麼
  • 取得總花費、請求數、token 用量、延遲與錯誤率,可依模型或供應商分組
  • 依模型、供應商、狀態、使用者、時間範圍與筆數篩選個別 LLM 請求
  • 列出代理追蹤摘要,並取得單一追蹤的完整 span 樹
  • 查詢平台偵測到的花費、延遲與錯誤率異常,可調整觀察視窗與靈敏度
  • 取得模型替換的節省建議,以及依終端使用者的用量明細
適用情境
適合已將 LLM 使用資料送入 Spanlens,並希望在 Cursor、Claude Desktop 或 Continue 中直接詢問花費、延遲、錯誤、追蹤或成本異常,而不必開啟儀表板的使用者。
執行需求
透過 npx 從 npm 套件以 stdio 在本機執行,需要 Node.js。需在 SPANLENS_API_KEY 提供 Spanlens 公開範圍 API 金鑰,缺少金鑰或使用完整存取金鑰時伺服器會拒絕啟動。需要連線 Spanlens API 的網路;SPANLENS_BASE_URL 可指向自架實例,SPANLENS_TIMEOUT_MS 設定每次呼叫逾時。
安裝前請注意
API 金鑰以明文存放在 IDE 設定檔中,可能因 dotfile 同步、螢幕分享或誤提交而外洩;伺服器只接受唯讀的公開範圍金鑰,外洩後也無法產生代理花費。伺服器會讀取工作區中的用量與追蹤資料(含終端使用者用量),並傳送到所設定的 API 端點。

安裝

在 SourceWeft 中

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

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

其他 MCP 客戶端

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

README

@spanlens/mcp-server

Query your LLM observability data from inside Cursor, Continue, or Claude Desktop. Powered by Spanlens.

Ask your IDE's agent things like "what's my OpenAI spend this week?", "any cost anomalies?", or "show me the most expensive trace today" — and get real answers from your Spanlens workspace through the Model Context Protocol.

30-second setup

1. Issue a public-scope Spanlens key

Public-scope keys (sl_live_pub_*) are read-only — they can query your dashboard data but cannot trigger LLM proxy spend. This server refuses to start with a full-access key because the credential will live in a plaintext config file in your IDE.

Create one at spanlens.io/projects → the Public Keys card at the top → + New public key. Copy the sl_live_pub_… value when it's shown.

2. Add the server to your IDE

Cursor — ~/.cursor/mcp.json (or workspace .cursor/mcp.json)
json
{  "mcpServers": {    "spanlens": {      "command": "npx",      "args": ["-y", "@spanlens/mcp-server"],      "env": { "SPANLENS_API_KEY": "sl_live_pub_..." }    }  }}
Claude Desktop — ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows)
json
{  "mcpServers": {    "spanlens": {      "command": "npx",      "args": ["-y", "@spanlens/mcp-server"],      "env": { "SPANLENS_API_KEY": "sl_live_pub_..." }    }  }}
Continue — ~/.continue/config.yaml
yaml
mcpServers:  - name: spanlens    command: npx    args: ['-y', '@spanlens/mcp-server']    env:      SPANLENS_API_KEY: sl_live_pub_...

3. Reload your IDE and start asking

The agent will discover seven tools and use them automatically when relevant.

What you can ask

QuestionTool called
"How much have we spent on LLMs this week?"get_stats
"Break down cost by model for the last 30 days"get_stats(groupBy=model)
"Which provider is costing us the most this week?"get_stats(groupBy=provider)
"Any cost or latency anomalies?"get_anomalies
"Show me the 10 most recent error calls on gpt-4o"query_requests
"List my recent agent runs"list_traces
"Walk me through trace abc123…"get_trace
"What models could we swap to save money?"get_savings
"Which end-user is driving the most spend?"get_user_analytics

Available tools

ToolWhat it returns
get_statsAggregate cost, request count, token usage, latency, error rate. Optional groupBy for a breakdown of cost, requests, latency and error rate: model returns one row per provider and model pair, and provider rolls those rows up into one row per provider, with latency and error rate weighted by request count.
query_requestsIndividual LLM requests with cost, latency, model, error message. Filter by model, provider, status, userId, since, limit.
list_tracesAgent trace summaries (name, status, duration, span count, total tokens, total cost) for discovering trace IDs. Filter by limit, status, since, query. Pair with get_trace for the full span tree.
get_traceFull agent span tree for a trace ID — every LLM/tool/retrieval span with timing, tokens, cost.
get_anomaliesCost / latency / error-rate anomalies the platform has detected. Optional since (observation window) and sigma (sensitivity).
get_savingsModel-swap recommendations with projected monthly savings and adoption status.
get_user_analyticsPer-end-user usage breakdown — total cost, request count, models touched, recent calls.

Safety

This server is designed for the IDE-config use case, where the credential sits in a plaintext file that's easy to leak (dotfile sync, screen shares, accidental commits). Two defenses:

  1. Public-scope keys only. The server boots, calls /api/v1/me/key-info against your workspace, and verifies the key has scope=public. If you accidentally paste a full-access sl_live_* key, the server refuses to start with a clear error pointing at the correct key type.
  2. Read-only at the API layer. Even if a public key leaks, it cannot call /proxy/* or /ingest/* — the Spanlens server enforces this with a 403 + PUBLIC_KEY_WRITE_FORBIDDEN code. The blast radius of a leak is "competitor sees my usage stats", not "competitor runs up my OpenAI bill".

Configuration

Environment variableDefaultNotes
SPANLENS_API_KEYrequiredA sl_live_pub_* key from the Public Keys card on /projects. The server refuses to start without one, and refuses to start with a sl_live_* (full) key.
SPANLENS_BASE_URLhttps://api.spanlens.ioOverride for self-hosted Spanlens. Trailing slashes are normalised.
SPANLENS_TIMEOUT_MS30000How long each API call may take, in milliseconds, before it fails with a timeout error. Applies to the startup key check and to every tool call. Accepts a whole number from 1 to 600000. Any other value stops the server at startup with an error that names the variable.

Self-hosted Spanlens

json
{  "mcpServers": {    "spanlens": {      "command": "npx",      "args": ["-y", "@spanlens/mcp-server"],      "env": {        "SPANLENS_API_KEY": "sl_live_pub_...",        "SPANLENS_BASE_URL": "https://spanlens.your-company.com"      }    }  }}

Links

License

MIT — see LICENSE in the repo root.

來源:packages/mcp-server/README.md,提交 e825a7e

工具

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

版本歷史

2
  1. v0.3.0最新Sep 28, 2026
  2. v0.2.1Sep 16, 2026

評分

已滿足適用檢查項的 50%

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

  • 近 30 天內可連通25 分

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

  • 已宣告認證方式10 分

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

  • 已列出工具15 分

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

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