Agentfit

io.github.MukundaKatta由 GitHub 帳號 MukundaKatta 發布v0.1.0更新於 Oct 24, 2026

Token-aware message truncation: fit a chat history into your model's context budget.

已驗證STDIO僅桌面開發者工具AI 與機器學習

概覽

AI 產生的概覽

本機 MCP 伺服器,讓助理估算 token 數量並把聊天記錄裁剪到模型的上下文預算內。

可以做什麼
  • 估算字串或聊天訊息陣列的 token 數,支援依模型區分的估算器系列(openai、anthropic、google、llama、default)
  • 依 maxTokens 預算裁剪聊天記錄,支援 drop-oldest、drop-middle 與 priority 策略,並遵循 preserveSystem、preserveFirstN、preserveLastN
  • 列出內建的估算器系列
  • 回傳結構化結果,包含保留與捨棄的訊息以及裁剪前後的 token 數;預算無法達成時回傳 fit: false 而非報錯
適用情境
適合讓助理檢查一段提示或對話記錄有多大,或在保留系統提示與最近幾輪的前提下,把長對話壓縮到 token 上限。在把上下文送給模型前做準備時很有用。
執行需求
以本機 stdio 程序執行,通常透過 npx 啟動 npm 套件 @mukundakatta/agentfit-mcp,因此需要 Node.js 與 npx。未宣告驗證、環境變數或標頭。僅支援桌面 MCP 用戶端,沒有網頁版。
安裝前請注意
傳給工具的聊天記錄由本機伺服器程序處理;README 說明 token 數為估算值,預算可能與服務商的精確計數不一致。此伺服器只回傳裁剪後的訊息,本身不會修改你的資料。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Agentfit,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

agentfit-mcp

MCP server for @mukundakatta/agentfit. Lets Claude Desktop, Cursor, Cline, Windsurf, Zed, or any other MCP client estimate token counts and fit a chat history into a model's context budget on demand.

bash
npx -y @mukundakatta/agentfit-mcp

Three tools:

  • count_tokens — estimate tokens in a string or chat-message array, with per-model estimator families (openai, anthropic, google, llama, default).
  • fit_messages — drop messages from a chat history until under a maxTokens budget. Supports drop-oldest, drop-middle, and priority strategies; honors preserveSystem, preserveFirstN, preserveLastN.
  • list_estimators — list the built-in estimator families.

Add to your client

Claude Desktop

Edit ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):

json
{  "mcpServers": {    "agentfit": {      "command": "npx",      "args": ["-y", "@mukundakatta/agentfit-mcp"]    }  }}

Cursor

~/.cursor/mcp.json:

json
{  "mcpServers": {    "agentfit": {      "command": "npx",      "args": ["-y", "@mukundakatta/agentfit-mcp"]    }  }}

Cline / Windsurf / Zed

Same shape as above. The server speaks plain MCP over stdio, so any client that supports stdio MCP servers will work.

Tool examples

count_tokens:

json
{ "input": "hello world", "model": "claude-sonnet-4-6" }

Returns:

json
{ "tokens": 4, "model": "claude-sonnet-4-6" }

fit_messages:

json
{  "messages": [    { "role": "system", "content": "You are precise." },    { "role": "user", "content": "long context..." },    { "role": "assistant", "content": "..." },    { "role": "user", "content": "final question" }  ],  "maxTokens": 8000,  "model": "claude-sonnet-4-6",  "preserveSystem": true,  "preserveLastN": 2,  "strategy": "drop-oldest"}

Returns:

json
{  "messages": [...],  "dropped": [...],  "tokens": { "before": 12000, "after": 7800, "budget": 8000 },  "fit": true}

fit_messages always returns a structured result and never throws across the wire: if the budget is unreachable even after dropping all non-protected messages, you get fit: false with the partial result so the caller can decide what to do.

Why a separate MCP server

@mukundakatta/agentfit is a zero-dependency JavaScript library. This package wraps it as an MCP server so it's accessible from inside any MCP-aware AI assistant: ask Claude "how many tokens is this transcript?" or "trim this chat to 8k tokens preserving the system prompt and last 2 turns" and the assistant calls these tools directly.

Sibling MCP servers

Part of the agent-stack series, all @mukundakatta/*-mcp:

License

MIT

來源:README.md,提交 6657bbb

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.1.0最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分