mcp-context-inspector
mcp-context-inspector
一个即插即用的 MCP 服务器 + 执行指标记录器,适用于任何调用工具的智能体。在你的智能体每次运行后,将 record_session(prompt, model_id, loop_result) 接入循环,即可免费获得:
一个真正的 MCP 服务器(Streamable HTTP),任何 MCP 客户端都可以连接——Claude Desktop、Cursor、你自己的聊天界面——暴露 7 个只读工具,涵盖会话历史、成本、Token/工具指标,以及...
上下文窗口浏览器——完全透明地展示模型上下文窗口中实际输入的内容,逐块呈现,配有诚实(明确标注为估算)的 Token 计数、比例分段条,以及每个块的可点击展开详情面板:

(截图来自与此工具一同构建的参考聊天界面——
sre-investigation-agent;上面的面板是任何 MCP 客户端查询get_context_timeline后得到的。)
大多数智能体可观测性工具只是重新展示你的 UI 已经显示过的数据。而这个工具展示了通常根本无法看到的内容:系统提示 vs 工具规格 vs 推理过程 vs 工具调用/结果 vs 最终答案,按照它们实际进入上下文的顺序,附带针对模型真实上下文窗口的累计 Token 总数——以及哪些块对最终用户可见,哪些是不可见的开销。
安装
uv add mcp-context-inspector # or: pip install mcp-context-inspector
# while co-developing locally against an editable checkout:
uv add --editable ../mcp-context-inspectorRelated MCP server: ai-usage-metrics-mcp
将其接入你的智能体
from metrics import store
session_id = store.record_session(prompt, model_id, loop_result)loop_result 是你的智能体循环返回的任何内容——此包只需要它看起来像这样:
{
"trace": [{"tool": "...", "args": {...}, "status": "ok"}, ...],
"turns": [{"input_tokens": int, "output_tokens": int, "latency_ms": int}, ...],
"input_tokens": int, "output_tokens": int, "total_tokens": int, "latency_ms": int,
"context_blocks": [ # optional — omit and you just lose the Explorer, nothing crashes
{"category": "system", "label": "...", "char_count": int, "token_estimate": int, "turn_n": int | None},
...
],
}context_blocks 类别:system、tools、user、reasoning、thinking、tool_call、tool_result(可选地携带 "status" 键用于对失败进行颜色编码)、answer。
运行服务器
uv run python -m mcp_server.server未设置 MCP_AUTH_TOKEN 时,会在启动时生成并打印一个 Token,信任模型与 Jupyter 服务器打印的 Token 相同。自行设置此项可在重启时获得稳定值。将任何 MCP 客户端指向 http://127.0.0.1:8787/mcp,并附带 Authorization: Bearer <token>。
存储后端
STORAGE_BACKEND=sqlite(默认,本地开发——data/metrics.db)或 STORAGE_BACKEND=dynamodb(设置 METRICS_TABLE/AWS_REGION)——无论哪种方式,函数签名相同,调用者无需知道哪个处于活动状态。
7 个 MCP 工具
get_session_metrics、get_token_breakdown、get_tool_metrics、get_agent_trace、get_cost_estimate、get_recent_sessions、get_context_timeline。普通的 REST 等效端点也暴露在 /api/* 下——这是一个适合 curl 的调试替代方案,调用相同的底层 metrics/store.py 函数。
相关仓库
sre-investigation-agent —— 此包从中提取并与之共同开发的参考聊天界面 + Bedrock 智能体。
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityAmaintenanceMCP-native agent evaluation and observability server. Log traces, evaluate output quality with 12 built-in rules (PII detection, prompt injection, cost thresholds), and track agent costs. Real-time dashboard, OTel-compatible spans. Self-hosted, MIT licensed.93467MIT
- Alicense-qualityDmaintenanceA MCP server for tracking AI usage metrics and structured logs across applications. Monitor model calls, analyze usage patterns, track costs, and debug AI interactions.10MIT
- AlicenseAqualityBmaintenanceAn MCP server that provides cost and reliability observability for LLM and agent workflows. It records model calls and allows querying and aggregating telemetry data through MCP tools.6MIT
- Alicense-qualityAmaintenanceAn MCP server that gives AI agents observability over their own tool calls, enabling auditing, cost tracking, latency analysis, and alerting.MIT
Related MCP Connectors
Agent Replay Debugger MCP — record every agent step + deterministic replay. Step-debugger for
Hosted MCP server for LLM cost estimation, model comparison, and budget-aware routing.
MCP server providing access to the Scorecard API to evaluate and optimize LLM systems.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/sohaibsohail98/mcp-context-inspector'
If you have feedback or need assistance with the MCP directory API, please join our Discord server