
Session Watcher
EOQ-based context economics for coding agents. Monitors LLM token cache with inventory theory, signals optimal session restart timing via live dashboard and terminal statusline. Zero context pollution β no metric ever enters the model's context.
Quick Install
Automated & IDE SetupCopy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
Manual Client & Custom JSON ConfigExpand JSON βΎ
Install Config Generator
π‘ Paste into ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows)
Capabilities & Tool Schemas (7)Self-reported
Inspect callable tools, capabilities, and parameters exposed to AI agents by Session Watcher.
start_watcherStart (or reuse) the dashboard server; returns its URL
stop_watcherStop the managed server
watcher_statusReport whether the server is running and its URL
rotate_sessionRotate to a new session ID
get_bucket_summaryReturn current context bucket structure (files, skills, tools) with metrics
prepare_handoffPersist selected paths + summary as a handoff package; returns a semantic token
Documentation Overview
Session Watcher
LLM context economics, in your terminal.
Session Watcher treats your prompt cache as inventory β it uses EOQ theory to measure whether the current context is still worth carrying, tracking restart pressure so you can decide when to hand off.
Documentation Β· npm Β· Paper Β· llms.txt
Quick Start Β· Install Β· How It Works Β· Context Buckets Β· Handoff Β· MCP Tools Β· Agents Β· Cite
What it does
Session Watcher reads your Claude Code transcript in real time and answers one question: is this session still worth carrying?
Most context tools optimize how you consume tokens β Headroom compresses, /compact shrinks, RTK filters. Session Watcher tracks when the cost curve is drifting, giving you the data to decide. They compose: run any pruning strategy you like, SW measures the cost curve so you can decide when to hand off.
SW reads from the transcript, never writes to it. The dashboard and statusline are pure observers; MCP tools return data for you to act on. Metrics stay on your screen, not in the model's context window.
How it works
Core model: B = cache_read_input_tokens (your context inventory). g = ΞL β ΞB (growth gap). x = L / B (position on the EOQ cost curve). br = mf Γ pp (bill premium β the percentage you're overpaying relative to optimal).
Lamp thresholds: green (br < 10%), amber (10β24%), red (β₯ 25%). See the paper for the full derivation β EOQ inventory theory mapped to LLM prompt caching.
Quick Start
Requires Node.js β₯ 22.16.
Opens a browser dashboard. The demo uses a pre-built anonymized session; replay uses your real transcript. Both are read-only β nothing is modified or uploaded.
Install
Plugin (recommended)
Or from within a Claude Code session:
This registers:
- MCP tools β available in every session
- SessionStart hook β auto-launches the dashboard server on each session
If you installed or updated in an already-running session, run /reload-plugins to activate.
Statusline
The plugin system does not yet support declaring a statusline. Add to your ~/.claude/settings.json:
Find your plugin path with:
Or check via claude plugin details session-watcher@session-watcher.
Note: the plugin cache path changes on version update. After updating, re-run the command above and update your statusline path.
One compact line:
Context Buckets
The bucket panel shows exactly which files, skills, and tools are consuming your context budget. Each path carries a token count β check or uncheck to preview how the restart cost changes. The U-curve ghost line updates in real time as you toggle.
Handoff
When it's time to restart, handoff preserves the state you want to keep. Run /sw-handoff to prepare a package β selected paths, working summary, next task. Then /clear, and in the fresh session run /sw-load to restore. Only what you chose is rebuilt β less ramp-up, less waste.
MCP Tools
Server lifecycle
| Tool | Description |
|---|---|
start_watcher | Start (or reuse) the dashboard server; returns its URL |
stop_watcher | Stop the managed server |
watcher_status | Report whether the server is running and its URL |
rotate_session | Rotate to a new session ID |
Handoff workflow
| Tool | Description |
|---|---|
get_bucket_summary | Return current context bucket structure (files, skills, tools) with metrics |
prepare_handoff | Persist selected paths + summary as a handoff package; returns a semantic token |
load_handoff | Load a handoff by token, free-text search, or auto-match for the current project |
Tools return data for you to decide on β only handoff injects context back into the model, and only the paths you explicitly selected.
Agent support
Session Watcher is agent-agnostic. The measurement pipeline only needs cache_read_input_tokens from each turn β it doesn't care which agent produced the transcript.
| Agent | Driver | Status |
|---|---|---|
| Claude Code | JSONL tail (native) | β |
| OpenCode | adapter-ready | pending |
| OpenClaw | adapter-ready | pending |
| Hermes | adapter-ready | pending |
| Aider | adapter-ready | pending |
Adding a new agent requires implementing one interface: extract cache_read_input_tokens from the agent's session transcript. See lib/extract.js for the Claude Code reference driver. PRs welcome.
Paper
Context Is Inventory: A Rent-or-Buy Model for Prompt-Cached LLM Sessions Longju Cheng (2026) Β· DOI:
10.5281/zenodo.21236704
The paper derives the full theoretical specification: EOQβLLM mapping, the 41.4% movable-cost bound, the ski-rental restart strategy, and measurements on 1,016 real session transcripts. See paper/paper.pdf.
Uninstall
Test
Citation
Privacy
- No remote telemetry.
- Transcripts are read locally and never uploaded.
- Local aggregate usage and handoff records are stored under
~/.session-watcher. - No transcript prose or file contents are stored in telemetry.
- Removing
~/.session-watcherdeletes all local state.
License
MIT
Related MCP Servers
View all alternativesFrequently Asked Questions about Session Watcher
How do I install the nomadop/session-watcher MCP server?
Add the following block to your claude_desktop_config.json under mcpServers: "mcpServers": { "session-watcher": { "command": "npx", "args": ["-y", "nomadop/session-watcher"] } }
What does nomadop/session-watcher do?
EOQ-based context economics for coding agents. Monitors LLM token cache with inventory theory, signals optimal session restart timing via live dashboard and terminal statusline. Zero context pollution β no metric ever enters the model's context.
Is the nomadop/session-watcher MCP server free to use?
Yes. nomadop/session-watcher is listed on AllMCPs as a free, open Model Context Protocol server you can install into Claude Desktop, Cursor, or any MCP-compatible client.