
Promptbudget Mcp
io.github.MukundaKatta由 GitHub 帳號 MukundaKatta 發布v0.2.0更新於 Oct 24, 2026
Token-budget-aware text handling: count, truncate, and chunk for LLM prompts.
概覽
本機 MCP 伺服器,在文字進入提示詞前依 token 預算進行計數、截斷與分塊。
- 可以做什麼
- 估算文字的 token 數,可對照 max_tokens 上限回傳是否放得下及超出量。
- 依 token 預算裁剪文字,支援 head、tail、head_tail 與 smart_cut 四種策略。
- 將長文字切成多個不超預算的區塊,可選擇重疊,方便 RAG 攝取。
- 適用情境
- 適合助理在組裝上下文、把聊天紀錄塞進模型視窗,或把長文件送進提示詞時,先做一次大小檢查或切分。
- 執行需求
- 以本機 stdio 程序執行,通常透過 npx 啟動 npm 套件 @mukundakatta/promptbudget-mcp;需要 Node.js 以及 Claude Desktop、Cursor、Cline、Windsurf 或 Zed 等 MCP 用戶端。未宣告帳號、金鑰或環境變數。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Promptbudget Mcp,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
@mukundakatta/promptbudget-mcp
MCP server for token-budget-aware text handling. Three tools: count, truncate, chunk. Use when an LLM is preparing context, fitting chat history, or feeding long source documents through a prompt.
Tools
Strategies for truncate
Real workflows
"Does this fit in my prompt?"
If fits: true, send as-is. If fits: false, decide between truncate_to_token_budget (lose info) or chunk_to_budget (multiple LLM calls).
"Make this fit, keep the latest"
"Ingest this 50k-token doc into my RAG"
The overlap_tokens value lets sentences at chunk boundaries still have surrounding context in the next chunk — important for RAG retrieval quality.
Token counting accuracy
The default chars_per_token = 4 is the OpenAI rule of thumb. It's accurate within ~10–15% for English. For accurate accounting against a specific model, plug in your real tokenizer's chars-per-token ratio:
For non-English text, divide further (Chinese is ~1 char/token, code is ~3 chars/token).
Install — Claude Desktop
Same shape for Cursor / Cline / Windsurf / Zed.
Run directly (no MCP client)
The server speaks MCP over stdio. Pair with mcptools or your client of choice. If nothing prints to the terminal, that is correct: stdio servers wait silently for an MCP client to connect.
Sibling library
The Rust crate promptbudget implements the same logic in pure Rust, in case you'd rather link the algorithm into a non-MCP context.
Changelog
- 0.2.0 (2026-05-10) — added
count_tokens(pre-flight check) andchunk_to_budget(split-with-overlap). README expanded with workflow examples + tokenizer ratio table. - 0.1.1 (2026-05-09) — added
mcpNamefield for MCP Registry compatibility. - 0.1.0 (2026-05-09) — initial release with
truncate_to_token_budget.
License
MIT OR Apache-2.0.
來源:packages/promptbudget-mcp/README.md,提交 6fad5bb
工具
0版本歷史
1- v0.2.0最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分