
Ai Token Counter
Built as a Cloudflare Workers MCP server that counts tokens for AI model inputs. The implementation runs on Cloudflare's edge network and exposes both REST and MCP interfaces over JSON-RPC 2.0 via streamable HTTP transport. Reach for this when you need to estimate token usage before sending prompts to language models, especially if you're working with Claude or other token-limited APIs and want to avoid surprises on cost or context window limits. The remote endpoint is already live, so you can integrate it without deploying your own infrastructure. Useful for pre-flight checks in applications that construct dynamic prompts or need to stay within specific token budgets.
- tools
- 4
- transport
- HTTP
- last updated
- May 16, 2026
Install
From registry metadata$ npx add-mcp https://api.lazy-mac.com/ai-token-counter/mcp --name ai-token-counterRun in your terminal. add-mcp asks which agents to add it to (Claude Code, Codex, Cursor and more). Add -g to install it for every project.
Review the command, arguments and environment values before installing. MCP servers run with your local permissions.
Other ways
Claude Code
$ claude mcp add --transport http ai-token-counter https://api.lazy-mac.com/ai-token-counter/mcpRun in your terminal. Add --scope user to make it available in every project.
Tools
Verified live · 4 toolsVerified live against the running server on Nov 6, 2026.
count_tokensCount tokens for a text string or chat messages array for any supported AI model (GPT-4o, Claude, Gemini, Mistral, Llama).3 params
Count tokens for a text string or chat messages array for any supported AI model (GPT-4o, Claude, Gemini, Mistral, Llama).
messagesarraymodelstringtextstringestimate_costEstimate the cost of an AI API call given model and token counts or text. Returns input/output/total cost and optional monthly projection.5 params
Estimate the cost of an AI API call given model and token counts or text. Returns input/output/total cost and optional monthly projection.
input_tokensintegermodel*stringoutput_tokensintegerrequests_per_daynumbertextstringget_model_pricingGet input/output pricing per 1M tokens for a specific AI model.1 params
Get input/output pricing per 1M tokens for a specific AI model.
model*stringlist_modelsList all supported AI models with their pricing and context windows.
List all supported AI models with their pricing and context windows.
No parameters. Call it with no arguments.
Sponsors
Readme
ai-token-counter-api
Cloudflare Workers MCP server: ai-token-counter. REST + MCP (JSON-RPC 2.0). Live: api.lazy-mac.com/ai-token-counter
Details
- Repository
- github.com/lazymac2x/ai-token-counter-api
- Category
- Cloud & Infrastructure
- Transport
- HTTP
- Registry
- MCP registry, active
- Tools verified
- Nov 6, 2026
More from lazymac2x
- Api Changelog Tracker
- Api Composition Gateway
- Api Contract Validator
- Api Diff Monitor
- Api Flow Analyzer
- Api Payload Auditor
- Api Perf Analyzer
- Api Request Deduplicator
- Api Response Cost Analyzer
- Api Schema Drift Detector
- Blog
- Citation Verifier
- Claude Skill Validator
- Code Explainer
- Code Pattern Risk Scanner
- Color Palette
- Cron Collision Detector
- Cron Monitor
- Cron Parser
- Crypto Signal
- Data Transform
- Diff Patch Tools
- Domain Intel
- Email Validator