Skip to main content
Glama
sohaibsohail98

mcp-context-inspector

Typing a prompt into Claude Code, then switching to the live ctxwindow dashboard and opening that session's Context Window Explorer blocks

Independent, unaffiliated open-source project. ctxwindow is not built, maintained, or endorsed by Anthropic. "Claude" and "Claude Code" are Anthropic's products; ctxwindow reads their publicly documented OpenTelemetry export and MCP protocol, nothing more.

The package/repo name on disk stays mcp-context-inspector; the product it ships is called ctxwindow (after its domain, ctxwindow.uk).

Quick start

Live demo, no install: https://ctxwindow.uk

Not yet published to PyPI, so run it from source (Python 3.11+):

git clone https://github.com/sohaibsohail98/mcp-context-inspector
cd mcp-context-inspector && uv run python -m mcp_server.server

With no MCP_AUTH_TOKEN set, the server generates and prints one on startup, using the same trust model as a Jupyter server's printed token.

Then sign in at /auth/login (locally or on the live demo) and the page hands you one command that writes the MCP connection and telemetry config into your own ~/.claude/settings.json (backed up first, merged, never overwritten):

curl -fsSL https://ctxwindow.uk/setup/install?t=<code> | sh

On Windows the page's Windows (PowerShell) tab gives you the equivalent irm "https://ctxwindow.uk/setup/install?os=windows&t=<code>" | iex instead.

The ?t= code is single-use and short-lived, so your real token is never in the command itself. Close and reopen Claude Code afterward, since env vars only load at process startup, then run one prompt and check "Test my connection" on the page.

Prefer to wire it up by hand, or connect claude.ai, the Messages API, or Copilot instead? See Usage and Run it locally.

Documentation

Why this exists

Most agent observability tools re-show data your own UI already displays. ctxwindow shows something you normally can't see at all: system prompt, tool specs, reasoning, tool calls and results, and the final answer, in the order they actually entered context. Each block is measured against the model's real context window and marked as either visible to the user or invisible overhead. Token counts are honest, labeled estimates, not exact provider usage (see Architecture for why that tradeoff is the right one here).

Anthropic's Claude Code docs page, "Explore the context window", is an interactive simulation of what loads into a session and what each file read costs. It motivated wanting the same visibility for an arbitrary agent loop, not just Claude Code.

The 8 MCP tools

Tool

Returns

Read/write

get_session_metrics

Session metadata + per-prompt tokens/latency/cost

Read

get_token_breakdown

Per-turn token/latency breakdown

Read

get_tool_metrics

Tool call counts by status

Read

get_agent_trace

Ordered tool-call sequence for one session

Read

get_cost_estimate

Estimated cost, one session or a time window

Read

get_recent_sessions

Most recent sessions, newest first

Read

get_context_timeline

Full context-window block breakdown

Read

record_session

Records one agent execution's metrics

Write (append-only)

Each tool ships explicit MCP annotations (readOnlyHint / destructiveHint / idempotentHint / openWorldHint), so a client can auto-approve the seven reads and prompt only for record_session. Nothing here reaches outside this server's own store (openWorldHint is always false), and record_session only ever inserts a new session — it never mutates or deletes one.

Plain REST equivalents are exposed under /api/*. Payload shapes are in Architecture.

Contributing

See CONTRIBUTING.md for lint, tests, and what a good PR looks like here. Run the suite with uv run pytest and lint with uv run ruff check ..

License

MIT licensed; see LICENSE. Developed alongside sre-investigation-agent, the reference chat UI and Bedrock agent this package was extracted from.

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