Skip to main content
Glama
sohaibsohail98

mcp-context-inspector

mcp-context-inspector

任意のツール呼び出しエージェント向けの、ドロップインMCPサーバー + 実行メトリクス記録ツール。エージェントのループで、実行後に record_session(prompt, model_id, loop_result) を指すだけで、以下の機能が無料で得られます。

  • 実際のMCPサーバー(Streamable HTTP)— Claude Desktop、Cursor、独自のチャットUIなど、任意のMCPクライアントが接続可能。セッション履歴、コスト、トークン/ツールメトリクスを公開する7つの読み取り専用ツールを提供し、さらに...

  • コンテキストウィンドウエクスプローラー — モデルのコンテキストウィンドウに何が入力されたかを、ブロックごとに完全に透明化。正直な(明示的に「推定値」とラベル付けされた)トークン数、比例セグメントバー、ブロックごとのクリック拡張可能な詳細パネルを備えています。

    Context Window Explorer

    *(このパッケージと同時に開発されたリファレンスチャットUI — sre-investigation-agent — のスクリーンショット。上記のパネルは、任意のMCPクライアントが get_context_timeline をクエリした際に取得できるものです。) *

ほとんどのエージェント観測ツールは、自身のUIが既に表示しているデータを再表示します。このツールは、通常はまったく見えないものを表示します。システムプロンプト vs. ツール仕様 vs. 推論 vs. ツール呼び出し/結果 vs. 最終回答、それらが実際にコンテキストに入力された順序、モデルの実際のコンテキストウィンドウに対する累計トークン数、そしてそれらのブロックのうちエンドユーザーに表示されるものと表示されないオーバーヘッドを明らかにします。

インストール

uv add mcp-context-inspector   # or: pip install mcp-context-inspector
# while co-developing locally against an editable checkout:
uv add --editable ../mcp-context-inspector

Related 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 が設定されていない場合、起動時に生成して出力します。Jupyterサーバーが出力するトークンと同じ信頼モデルです。再起動後も安定した値が必要な場合は、自分で設定してください。任意のMCPクライアントを http://127.0.0.1:8787/mcpAuthorization: Bearer <token> ヘッダー付きで接続します。

ストレージバックエンド

STORAGE_BACKEND=sqlite(デフォルト、ローカル開発 — data/metrics.db)または STORAGE_BACKEND=dynamodbMETRICS_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 — このパッケージの基盤となり、同時に開発されたリファレンスチャットUI + Bedrockエージェント。

A
license - permissive license
-
quality - not tested
C
maintenance

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

  • A
    license
    A
    quality
    A
    maintenance
    MCP-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.
    9
    346
    7
    MIT
  • A
    license
    A
    quality
    B
    maintenance
    An 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.
    6
    MIT
  • A
    license
    -
    quality
    A
    maintenance
    An MCP server that gives AI agents observability over their own tool calls, enabling auditing, cost tracking, latency analysis, and alerting.
    MIT

View all related MCP servers

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.

View all MCP Connectors

Latest Blog Posts

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