token-pilot
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@token-pilotoutline main.ts with smart_read"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Token Pilot
Token-efficient AI coding, enforced. Cuts context consumption in AI coding assistants by up to 90% without changing the way you work.
Three layers, each useful on its own, stronger together:
MCP tools — structural reads (
smart_read,read_symbol,read_for_edit, …). Ask for an outline or load one function by name instead of the whole file.PreToolUse hooks — intercept heavy native tool calls (
Readon large files, recursiveGrep, unboundedgit diff) and redirect to token-efficient alternatives.tp-*subagents — Claude Code delegates with MCP-first behaviour and tight response budgets.
How It Works
Traditional: Read("user-service.ts") → 500 lines → ~3000 tokens
Token Pilot: smart_read("user-service.ts") → 15-line outline → ~200 tokens
read_symbol("UserService.updateUser") → 45 lines → ~350 tokens
After edit: read_diff("user-service.ts") → ~20 tokensFiles under 200 lines are returned in full — zero overhead for small files.
Benchmarks
Measured on public open-source repos. Files ≥50 lines only:
Repo | Files | Raw Tokens | Outline Tokens | Savings |
token-pilot (TS) | 55 | 102,086 | 8,992 | 91% |
express (JS) | 6 | 14,421 | 193 | 99% |
fastify (JS) | 23 | 50,000 | 3,161 | 94% |
flask (Python) | 20 | 78,236 | 7,418 | 91% |
Total | 104 | 244,743 | 19,764 | 92% |
smart_readoutline savings only. Real sessions additionally benefit from session cache,read_symbol, andread_for_edit. Reproduce:npx tsx scripts/benchmark.ts.
Quick Start
npx -y token-pilot initCreates (or merges into) .mcp.json with token-pilot + context-mode, then prompts to install tp-* subagents. Restart your AI assistant to activate.
What You Get
22 MCP tools — structural reads, symbol search, git analysis, session analytics → tools reference
PreToolUse hooks — block heavy
Grep/Bash/Readcalls; redirect to efficient alternatives → hooks & modes25
tp-*subagents (Claude Code only) — MCP-first delegates with haiku/sonnet model tiers and budget enforcement → agents referenceTool profiles — trim advertised
tools/listto save ~2 k tokens per session → profiles & config
Client Support Matrix
Client | MCP tools | PreToolUse hooks |
|
Claude Code | ✅ | ✅ | ✅ |
Cursor | ✅ | ✅ | ❌ |
Codex CLI | ✅ | ✅ | ❌ |
Gemini CLI | ✅ | ✅ | ❌ |
Cline (VS Code) | ✅ | ✅ | ❌ |
Antigravity | ✅ | ✅ | ❌ |
Manual config snippets for each client → installation guide
Enforcement Mode
TOKEN_PILOT_MODE controls how aggressively Token Pilot redirects heavy native tool calls:
Value | Behaviour |
| Allow all — hooks pass through, advisory notes only |
| Block heavy |
| Deny + auto-cap MCP output ( |
TOKEN_PILOT_MODE=strict npx token-pilotEcosystem
Token Pilot owns input tokens — the stuff Claude reads from files, git, search. The other half of a session (what Claude writes back, how it executes code, how it remembers state across days) is owned by separate tools. They compose cleanly:
Tool | Owns | Typical savings |
Token Pilot | code reads, git, search | 60-90% input |
Claude's response prose (terse-speak skill) | ~75% output | |
the structural indexer Token Pilot rides on | foundation | |
sandboxed shell / python / js execution | 90%+ on big stdout |
A session that pairs token-pilot + caveman typically hits ~85-90% total reduction — each cuts a different half, no overlap. Install what you need; none of them assume the others are present.
Rules of thumb: read code → smart_read/read_symbol; execute code with big output → context-mode execute; bash-only agent → ast-index CLI. Never copy the whole stack into CLAUDE.md — Token Pilot's doctor warns when CLAUDE.md exceeds 60 lines.
Supported Languages
TypeScript, JavaScript, Python, Go, Rust, Java, Kotlin, C#, C/C++, PHP, Ruby. Non-code (JSON/YAML/Markdown/TOML) gets structural summaries. Regex fallback handles most other languages.
Update / New Machine
Claude Code (plugin — recommended):
# Install on a new machine:
claude plugin marketplace add https://github.com/Digital-Threads/token-pilot
claude plugin install token-pilot@token-pilot
# Update to latest:
claude plugin update token-pilotOther clients (Cursor, Codex, Cline, …):
# Install on a new machine:
npx -y token-pilot init
# Update to latest — npx always pulls fresh, just restart your client.
# Or if installed globally:
npm i -g token-pilot@latest
npx token-pilot install-hook
npx token-pilot install-agents --scope=user --forceTips for Claude Code 2.1.139+
The May 2026 Claude Code update changed a few things that affect how token-pilot is invoked. Nothing breaks on older versions — these are quality-of-life notes for the newer ones.
Run a tp-* agent directly without the
plugin:prefix.claude --agent tp-debugger "fix the stack trace"now works the same as--agent token-pilot:tp-debugger. The Task tool dispatcher resolves the short name automatically.Cold ast-index calls — raise
MCP_TOOL_TIMEOUT. The firstfind_usages/outline/read_symbolon a large repo triggers an index build. Default per-MCP-tool timeout (60 s) is enough for ~50k-file repos; bigger ones benefit fromMCP_TOOL_TIMEOUT=120000in~/.claude/settings.json. Subsequent calls hit the cache and return in ~50 ms.Background sessions with
--mcp-config. Dispatching a worker viaclaude agentsor--bgwith--mcp-config /path/to/other.jsonswaps the MCP set for that session. Iftoken-pilotis not in the override config, MCP tools (smart_read,find_usages, …) are unavailable in that worker even though the hooks (Read / Edit / Bash / Grep / Task) still fire — hooks are project-level, MCP tools are session-level. Addtoken-pilotto the override config or skip--mcp-config.claude plugin details token-pilot. Shows the projected per-turn token cost, the hook event names, and the MCP server entry. The skill list, the agent list, and the LSP list are all auto-discovered from the canonical sub-folders.
Troubleshooting
npx token-pilot doctor # diagnose: ast-index, config, upstream drift
# "ast-index not found" → npx token-pilot install-ast-index
# "hooks not firing" → restart your AI assistantCredits
Built on ast-index · @ast-grep/cli · MCP SDK · chokidar
License
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
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/Digital-Threads/token-pilot'
If you have feedback or need assistance with the MCP directory API, please join our Discord server