ai-token-counter

v1.0.0
io.github.lazymac2x/ai-token-counter Checked 16 hours ago Published 6 months ago

Cloudflare Workers MCP server: ai-token-counter

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

count_tokens

Count tokens for a text string or chat messages array for any supported AI model (GPT-4o, Claude, Gemini, Mistral, Llama).

ParameterTypeDescription
messagesarrayChat messages array in OpenAI/Anthropic format.
modelstringModel ID, e.g. gpt-4o, claude-sonnet-4. Defaults to gpt-4o.
textstringPlain text to count tokens for.

estimate_cost

Estimate the cost of an AI API call given model and token counts or text. Returns input/output/total cost and optional monthly projection.

ParameterTypeDescription
model *stringModel ID, e.g. gpt-4o, claude-opus-4, gemini-2.0-flash.
input_tokensintegerNumber of input tokens.
output_tokensintegerNumber of output tokens.
requests_per_daynumberIf given, adds daily/monthly/yearly cost projection.
textstringText to tokenize for input (if input_tokens not given).

get_model_pricing

Get input/output pricing per 1M tokens for a specific AI model.

ParameterTypeDescription
model *stringModel ID, e.g. gpt-4o, claude-haiku-3, llama-3-70b.

list_models

List all supported AI models with their pricing and context windows.