llm-cost-estimator-mcp
v0.3.1
Published
MCP server for LLM token counting and multi-model cost estimation (GPT-4o, Claude, Gemini, and 25+ models). Local-first, no API key.
Maintainers
Readme
llm-cost-estimator-mcp
An MCP (Model Context Protocol) server that gives Claude, Cursor, or any MCP client the ability to count tokens and estimate LLM costs across GPT-4o, Claude, Gemini, DeepSeek, Mistral, Llama, Grok, and 25+ models — locally, with no API key.
It reuses the exact same tokenizer + pricing + estimator core as the LLM Cost & Token Estimator VS Code extension in this repo.
Tools
| Tool | Description |
| --- | --- |
| estimate_cost | Token count + cost across multiple models for a piece of text. Returns a Markdown table and structured JSON. Args: text, models?, outputTokens?, currency?. |
| count_tokens | Token count for one model. Args: text, model?. OpenAI is exact (tiktoken); others are flagged estimates. |
| list_models | All model keys with provider, prices (USD/1M), and context window. |
⚠️ Prices are representative placeholders — verify against each provider's official pricing page. OpenAI counts are exact; all other providers are approximated via an OpenAI encoding and flagged as estimates.
Build (from source)
The server reuses the extension's core in ../src (whose files import
js-tiktoken), so install the repo-root dependencies first:
npm install # at the repo ROOT, once (provides the reused core's deps)
cd mcp-server
npm install
npm run build # -> dist/index.js
npm test # builds, then runs a real stdio MCP handshakeEnd users don't need this — they just npx -y llm-cost-estimator-mcp once it's
published (the published dist/index.js is fully self-contained).
Connect it
The server speaks MCP over stdio, so any client launches it as a subprocess.
Use the absolute path to mcp-server/dist/index.js.
Claude Desktop
Edit claude_desktop_config.json
(Windows: %APPDATA%\Claude\claude_desktop_config.json,
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"llm-cost-estimator": {
"command": "node",
"args": ["C:/path/to/llm-cost-estimator/mcp-server/dist/index.js"]
}
}
}Restart Claude Desktop, then ask: "Estimate the cost of this prompt on GPT-4o vs Claude Sonnet vs Gemini."
Claude Code (CLI)
claude mcp add llm-cost-estimator -- node /abs/path/to/mcp-server/dist/index.jsCursor
Add to ~/.cursor/mcp.json (global) or .cursor/mcp.json (per-project):
{
"mcpServers": {
"llm-cost-estimator": {
"command": "node",
"args": ["/abs/path/to/mcp-server/dist/index.js"]
}
}
}After publishing to npm (optional)
Once this package is published, clients can launch it without a local build:
{
"mcpServers": {
"llm-cost-estimator": { "command": "npx", "args": ["-y", "llm-cost-estimator-mcp"] }
}
}License
MIT — see ../LICENSE.
