Skip to main content
Glama

TokenBudget

Estimate token counts per tokenizer

count_tokens
Read-onlyIdempotent

Estimate how many tokens a text is for each tokenizer family (OpenAI o200k, Claude legacy and 2026, Gemini, DeepSeek, Mistral, Qwen), with an error band. Estimates only; for exact counts use the provider's count endpoint.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "count_tokens"
  }
}

Input Schema

NameRequiredDescriptionDefault
textNoPrompt text. Counted with an estimator, never stored.
modelsNoModel ids to compare, e.g. ["claude-sonnet-5-5", "gpt-6.2-sol", "gemini-3.8-flash"]. Omit to compare every listed model. list_models gives every id.
messagesNoChat messages [{role, content}]. Counted with an estimator, never stored.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnly, idempotent and closed-world, so the bar is lower, and the description still adds the important behavioral trait that results are approximate with an error band. It stops short of saying how wide that band is or whether estimate quality varies by family, which would have made it a 5.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences with no filler and the purpose is front-loaded, which is strong. The parenthetical enumeration of six tokenizer families consumes much of the text without earning much, since the models parameter already governs which families are compared.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a three-parameter, all-optional read tool with no output schema, the definition covers purpose, scope, approximation caveat and a fallback route, which is nearly everything an agent needs. What is missing is only the shape of the returned error band and how to choose between the text and messages inputs.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so per-parameter documentation is already handled and baseline 3 applies. The description adds nothing about the meaningful ambiguity the schema leaves open: whether text and messages are alternatives or can be combined, and how the models array maps onto the listed tokenizer families.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ("estimate how many tokens a text is") and enumerates the tokenizer families covered, so an agent knows exactly what dimension of comparison it gets. It also distinguishes itself from the exact-count route, which no sibling name alone would establish.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

"Estimates only; for exact counts use the provider's count endpoint" gives an explicit when-not-to-use condition and names the alternative. The gap is that it does not relate itself to siblings like estimate_cost or check_context_fit, so the agent must infer whether this is the pre-flight step for those.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources