
Token Pilot
io.github.Digital-Threads由 GitHub 帳號 Digital-Threads 發布v2.0.0更新於 Nov 7, 2026
Save up to 80% tokens when AI reads code via AST-aware structural reading
發布方自己的服務:QuickBooks Connector by Meridian
概覽
本機 MCP 伺服器,為 AI 程式助理提供以 AST 為基礎的結構化程式碼讀取,大幅減少每個檔案耗用的上下文 token。
- 可以做什麼
- 以結構化方式讀取程式碼:大綱、依名稱讀取單一符號、為編輯準備的檢視,而非整個檔案
- 搜尋符號並以精簡輸出分析 git 歷史與差異
- 進行模組路由並檢視工作階段 token 統計
- 透過鉤子攔截重量級原生 Read、Grep、Bash 呼叫並改導向更省 token 的方式
- 用工具設定檔裁剪對外公布的工 具清單,節省每次工作階段的 token
- 適用情境
- 當程式助理因為讀取大型檔案、遞迴搜尋或無上限的 git diff 而大量耗用上下文時適用,可換得更小、更有針對性的讀取。對支援語言的中大型儲存庫最有用;小檔案本來就會完整回傳。
- 執行需求
- 透過 npm 套件 token-pilot 以 stdio 在本機執行(需要 Node.js/npx)。使用 init 指令完成設定,它會寫入或合併 MCP 設定項目。鉤子攔截僅針對 Claude Code 與 Codex CLI 撰寫,其他用戶端只能使用 MCP 工具。未宣告需要帳號、API 金鑰或環境變數。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Token Pilot,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
Token Pilot
Token-efficient AI coding, enforced. Cuts context consumption in AI coding assistants by up to 90% without changing the way you work.
Why it matters more now: as frontier models move up in price, the tokens you don't spend reading code are worth more, not less. The savings are in tokens; the value is in tokens × price. Token Pilot keeps the expensive main thread lean so the premium model spends its budget on reasoning, not on re-reading files.
Two 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.
How It Works
Files under 200 lines are returned in full — zero overhead for small files.
Benchmarks
Measured on public open-source repos. Files ≥50 lines only:
smart_readoutline savings only. Real sessions additionally benefit from session cache,read_symbol, andread_for_edit. Reproduce:npx tsx scripts/benchmark.ts.
Quick Start
Creates (or merges into) .mcp.json with token-pilot + context-mode. Restart your AI assistant to activate.
What You Get
- 25 MCP tools — structural reads, symbol search, git analysis, module routing, session analytics → tools reference
- PreToolUse hooks — block heavy
Grep/Bash/Readcalls; redirect to efficient alternatives → hooks & modes - Tool profiles — trim advertised
tools/listto save ~2 k tokens per session → profiles & config
Client Support Matrix
Hooks are written for Claude Code (the plugin's own hooks/hooks.json, or
~/.claude/settings.json for an npm install) and for Codex CLI
(npx token-pilot install-hook --client=codex, then /hooks inside Codex to
trust them). The other clients get the MCP tools; their hook systems exist but
token-pilot does not write to them yet.
On Claude Code 2.1.275 and later the plugin runs its hooks inside Claude Code as a mod — no process per tool call, and a big Read comes back as an outline instead of a refusal. Older versions keep the command hooks → Claude Code mods
Manual config snippets for each client → installation guide
Enforcement Mode
TOKEN_PILOT_MODE controls how aggressively Token Pilot redirects heavy native tool calls:
Ecosystem
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:
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):
Other clients (Cursor, Codex, Cline, …):
Tips 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.
-
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. On a Claude Code that loads the token-pilot mod, the hooks (Read / Bash / Grep / Edit in strict mode / Agent) see the tools are missing and step aside. The command hooks of an older Claude Code only see a server turned off in/mcp. Addtoken-pilotto the override config if you want the tools. -
claude plugin details token-pilot. Shows the projected per-turn token cost, the hook event names, and the MCP server entry. The skill list and the LSP list are all auto-discovered from the canonical sub-folders.
Power-user — undocumented Claude Code features that pair with token-pilot
These fields come from reverse-engineering @anthropic-ai/[email protected]
source (see the May 2026 Habr write-up). They work today but are
not in the official Claude Code docs, so use at your own risk.
Bootstrap-once hook (once: true)
The plugin ships a SessionStart hook flagged once: true —
Claude Code runs it once per project then auto-removes the entry.
It surfaces a friendly hint when
install-ast-index hasn't been run yet. v0.35.0+.
Async telemetry (async: true)
PostToolUse hooks (Bash, Task) are marked async: true so they
no longer add wall-clock to the hot path — telemetry writes fire
in the background.
Auto-mode permissions (user-side)
If you want full auto-approval for safe commands, the YOLO classifier reads natural-language environment descriptions:
token-pilot's enforcement still runs on top (raw Read on large files is denied first, regardless of autoMode).
Permission rule syntax cheat-sheet
* matches inside word boundaries (shell-glob); ** is recursive.
The if field on hooks uses the same syntax.
Experimental: transparent Read rewrite
Set TOKEN_PILOT_HOOK_REWRITE=1 to swap the "deny + suggest" Read
hook behaviour for an updatedInput rewrite — Claude Code's
undocumented field that silently bounds the Read to its first 200
lines instead of bouncing the call. The structural summary still
rides along in additionalContext. Default OFF because the field
is undocumented and may change.
Experimental: SubagentStop budget feedback (CC 2.1.163+)
Every subagent completion lands a task-telemetry row via the
SubagentStop hook (that's how stats --tasks knows what you
dispatched). With TOKEN_PILOT_SUBAGENT_FEEDBACK=1 the same hook also
returns additionalContext — when a token-pilot workflow fan-out is
at ≥90 % of its token ceiling, each completing agent gets a wind-down
note so a hundred-agent /workflow run stops before blowing the
budget.
Requires Claude Code 2.1.163+. Returning additionalContext from
SubagentStop is only honoured there; older Claude Code labels it a
hook error. Default OFF for that reason — enable only once
claude --version reports 2.1.163 or later.
What's new for Claude Code 2.1.151+
These notes are about behaviour you'll see automatically once you
update both Claude Code and token-pilot@latest. No extra
configuration required.
Session title badge ([TP] Nk saved)
The SessionStart hook now sets the window/tab title to the cumulative
token savings for the current project, using Claude Code 2.1.152's
hookSpecificOutput.sessionTitle field. You'll see a badge like
[TP] 1.2M saved in the title bar so you can confirm at a glance
that the plugin is doing its job.
Hardened skills (disallowed-tools)
The three bundled skills (guide, install, stats) declare
disallowed-tools (Claude Code 2.1.152+) so a runaway model can't
issue Write / Edit / Task while the skill is on display. The
install skill keeps Bash because it has to run
npx token-pilot install-ast-index; the other two have Bash
disallowed too.
Auto mode on third-party providers
Claude Code 2.1.158 opened auto mode to Bedrock / Vertex / Foundry
on Opus 4.7 + 4.8. If you're on one of those, opt in with
CLAUDE_CODE_ENABLE_AUTO_MODE=1. token-pilot's deny-Read /
deny-Bash gates still run on top — auto mode never bypasses them.
Fleet workflows (v0.38.0)
When you fan a task across many subagents — via Claude Code's
/workflow, the Agent tool, or your own orchestration — token-pilot
can treat the whole run as one budgeted, telemetry-tagged unit.
token-pilot owns the workflow boundary, so this works regardless of whether Claude Code propagates a workflow id. You wrap the batch:
While a workflow is active:
- Every
event:"task"/denied/diagnosticrow inhook-events.jsonlcarriesworkflow_id, so you can slice one fan-out run out of the global log. - The PreToolUse:Agent hook watches the token ceiling. At ≥90 % it
adds a wind-down note ("finish in-flight
work rather than starting new branches") and logs a
workflow_near_budgetdiagnostic — visible inworkflow status. Dispatch is never hard-blocked on budget (a half-finished fan-out is worse than a small overrun). - The window title switches to
[TP] wf · N tasks · X%so a long run shows live progress.
Claude Code's own /workflow (2.1.154+) does not expose a
per-workflow id env var to subagents (verified against the 2.1.161
bundle — it has only a CLAUDE_CODE_WORKFLOWS feature flag). So
token-pilot's workflows are independent: they rely on our own
TOKEN_PILOT_WORKFLOW_ID. If CC adds a per-workflow env var later,
activeWorkflowId() already probes for it — no config change needed.
Troubleshooting
Credits
Built on ast-index · @ast-grep/cli · MCP SDK · chokidar
License
MIT
來源:README.md,提交 29ad6ed
工具
0版本歷史
7- v2.0.0最新Nov 7, 2026
- v1.0.4Oct 6, 2026
- v1.0.3Oct 4, 2026
- v1.0.2Oct 4, 2026
- v0.53.1Oct 4, 2026
- v0.53.0Sep 24, 2026
- v0.52.1Sep 16, 2026
評分
已滿足適用檢查項的 40%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分
請在儲存庫或註冊中心條目中宣告授權條款。
其他 Pilot 整合
QuickBooks Connector by Meridian
com.pilot.meridian官方發布者
讓助理透過託管的遠端連接器讀取與寫入 QuickBooks Online 公司資料。
AI Agent Connector by Meridian
com.pilot.meridian官方發布者
讓 AI 助理以授權的讀取或寫入權限連接 Xero,並可跨多個組織操作。

XuLan ScreenPilot
由 GitHub 帳號 dahuam 發布
將真實的 Windows 螢幕轉換為帶編號的元素表,供你的 AI 代理程式操作。AI 翻譯

Covenant AAP - hosted developer pilot
由 GitHub 帳號 covenant-common 發布
託管的市場與合約起草伺服器:搜尋公開刊登、產生交易紀錄、起草與比對條款,並複核協議證據。
Tag Pilot Search Console
由 GitHub 帳號 tagpilot 發布
唯讀的 Google Search Console MCP 伺服器,讓助理查詢你網站的點擊、曝光、CTR、排名、網站地圖與索引狀態。