
Agentfit
Wraps the agentfit JavaScript library as an MCP server so Claude and other clients can estimate token counts and truncate chat histories on the fly. Exposes three tools: count_tokens for quick estimation across OpenAI, Anthropic, Google, and Llama tokenizer families; fit_messages to drop messages from a history until it fits a budget, with strategies like drop-oldest or drop-middle and options to preserve system prompts or the last N turns; and list_estimators to see what's available. Useful when you need to ask your assistant "trim this transcript to 8k tokens" or check token usage mid-conversation without leaving your editor. Runs via npx with zero dependencies, works over stdio with any MCP client.
- GitHub stars
- 1
- tools
- 3
- transport
- STDIO
- last updated
- Apr 27, 2026
Tools
3 toolsPublic tool metadata for what this MCP can expose to an agent.
count_tokensestimate tokens in a string or chat-message array, with per-model estimator families (openai, anthropic, google, llama, default).
estimate tokens in a string or chat-message array, with per-model estimator families (openai, anthropic, google, llama, default).
No parameter schema in public metadata yet.
fit_messagesdrop messages from a chat history until under a `maxTokens` budget.
drop messages from a chat history until under a `maxTokens` budget.
No parameter schema in public metadata yet.
list_estimatorslist the built-in estimator families.
list the built-in estimator families.
No parameter schema in public metadata yet.
Sponsors
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.
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 amaxTokensbudget. Supports drop-oldest, drop-middle, and priority strategies; honorspreserveSystem,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):
{
"mcpServers": {
"agentfit": {
"command": "npx",
"args": ["-y", "@mukundakatta/agentfit-mcp"]
}
}
}
Cursor
~/.cursor/mcp.json:
Details
- Repository
- github.com/mukundakatta/agentfit-mcp
- Website
- github.com/MukundaKatta/agentfit-mcp
- Category
- Communication & Messaging
- Package
@mukundakatta/agentfit-mcp- Transport
- STDIO
- Registry
- MCP registry, active