Cloudflare Workers MCP server: ai-token-counter
Maintain this server? Claim it
Call this server's tools from your browser. Nothing to install.
Requests go through mcptry because browsers can't call most MCP servers directly. Header values are sent to the server for that request only and are never stored or logged.
Tool list from our last check. Connect live to refresh it.
Count tokens for a text string or chat messages array for any supported AI model (GPT-4o, Claude, Gemini, Mistral, Llama).
Plain text to count tokens for.
Model ID, e.g. gpt-4o, claude-sonnet-4. Defaults to gpt-4o.
Chat messages array in OpenAI/Anthropic format.
This tool isn't marked read-only, so it may change something on the server or in an account you connected.
Count tokens for a text string or chat messages array for any supported AI model (GPT-4o, Claude, Gemini, Mistral, Llama).
| Argument | Type |
|---|
| Description |
|---|
| text | string | Plain text to count tokens for. |
| model | string | Model ID, e.g. gpt-4o, claude-sonnet-4. Defaults to gpt-4o. |
| messages | array | Chat messages array in OpenAI/Anthropic format. |
{
"type": "object",
"properties": {
"text": {
"type": "string",
"description": "Plain text to count tokens for."
},
"model": {
"type": "string",
"description": "Model ID, e.g. gpt-4o, claude-sonnet-4. Defaults to gpt-4o."
},
"messages": {
"type": "array",
"items": {
"type": "object"
},
"description": "Chat messages array in OpenAI/Anthropic format."
}
}
}Estimate the cost of an AI API call given model and token counts or text. Returns input/output/total cost and optional monthly projection.
| Argument | Type | Description |
|---|---|---|
| text | string | Text to tokenize for input (if input_tokens not given). |
| 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. |
{
"type": "object",
"required": [
"model"
],
"properties": {
"text": {
"type": "string",
"description": "Text to tokenize for input (if input_tokens not given)."
},
"model": {
"type": "string",
"description": "Model ID, e.g. gpt-4o, claude-opus-4, gemini-2.0-flash."
},
"input_tokens": {
"type": "integer",
"description": "Number of input tokens."
},
"output_tokens": {
"type": "integer",
"description": "Number of output tokens."
},
"requests_per_day": {
"type": "number",
"description": "If given, adds daily/monthly/yearly cost projection."
}
}
}Get input/output pricing per 1M tokens for a specific AI model.
| Argument | Type | Description |
|---|---|---|
| model* | string | Model ID, e.g. gpt-4o, claude-haiku-3, llama-3-70b. |
{
"type": "object",
"required": [
"model"
],
"properties": {
"model": {
"type": "string",
"description": "Model ID, e.g. gpt-4o, claude-haiku-3, llama-3-70b."
}
}
}List all supported AI models with their pricing and context windows.
No arguments.
{
"type": "object",
"properties": {}
}