ai-token-counter
v1.0.0Cloudflare 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).
| Parameter | Type | Description |
|---|---|---|
messages | array | Chat messages array in OpenAI/Anthropic format. |
model | string | Model ID, e.g. gpt-4o, claude-sonnet-4. Defaults to gpt-4o. |
text | string | Plain 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.
| Parameter | Type | Description |
|---|---|---|
model * | string | Model ID, e.g. gpt-4o, claude-opus-4, gemini-2.0-flash. |
input_tokens | integer | Number of input tokens. |
output_tokens | integer | Number of output tokens. |
requests_per_day | number | If given, adds daily/monthly/yearly cost projection. |
text | string | Text to tokenize for input (if input_tokens not given). |
get_model_pricing
Get input/output pricing per 1M tokens for a specific AI model.
| Parameter | Type | Description |
|---|---|---|
model * | string | Model ID, e.g. gpt-4o, claude-haiku-3, llama-3-70b. |
list_models
List all supported AI models with their pricing and context windows.