
Ai Token Counter
Count tokens in drafts and tool outputs from your agent so you can size prompts, control cost, and avoid context overflows.
Overview
ai-token-counter is an MCP server for the Build phase that counts LLM tokens through a hosted Cloudflare Workers MCP endpoint.
What is this MCP server?
- Remote MCP token counter on Cloudflare Workers
- Helps estimate context usage before sending large repo dumps to models
- Supports cost-aware solo builder workflows with LLM APIs
- Natural pair with ai-prompt-optimizer and ai-rate-limit-tracker
- GitHub: lazymac2x/ai-token-counter-api for implementation details
- Server version 1.0.0
- One streamable-http remote endpoint
- Hosted MCP on api.lazy-mac.com (Cloudflare Workers)
What problem does it solve?
You ship oversized prompts to agents without knowing token cost or whether you will exceed the context window.
Who is it for?
Indie developers tuning agent context, RAG snippets, and long SKILL.md loads who want quick counts inside the IDE.
Skip if: Teams that need enterprise-grade usage billing tied to invoices rather than ad-hoc MCP estimates.
What do I get? / Deliverables
With the MCP remote connected, your agent can count tokens on drafts so you right-size context before calling the main model.
- MCP tools that return token counts for agent-supplied text
- Smaller, cheaper prompts and fewer context-overflow failures
Recommended MCP Servers
Journey fit
Token budgeting is core while authoring agent flows and integrations, before you optimize spend in later Operate work. Counters attach to the same agent-tooling shelf as prompt design, MCP wiring, and context window planning.
How it compares
MCP token estimator endpoint, not a local tiktoken script or observability warehouse.
Common Questions / FAQ
Who is ai-token-counter for?
Solo builders using MCP agents who need token counts while crafting prompts, skills, and large codebase contexts.
When should I use ai-token-counter?
Use it before sending big files to the model, when trimming system prompts, or when comparing model context limits.
How do I add ai-token-counter to my agent?
Add https://api.lazy-mac.com/ai-token-counter/mcp as a streamable-http MCP remote in your agent client settings.