
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 分