Skip to main content
Glama

count_tokens

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textNoPlain text to count tokens for.
modelNoModel ID, e.g. gpt-4o, claude-sonnet-4. Defaults to gpt-4o.
messagesNoChat messages array in OpenAI/Anthropic format.

TDQS

B3.4/5.0
Behavior2/5

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

No annotations are provided, so the description must carry behavioral transparency. It does not disclose the return format (total count vs per-message), tokenization methodology, or any limitations. The output is unspecified, which is a significant gap.

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

Conciseness5/5

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

The description is a single, front-loaded sentence that conveys the core purpose without wasted words. It is directly readable and easy to parse.

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

Completeness2/5

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

Given three optional parameters, no output schema, and no annotations, the description is insufficiently complete. It omits return value details, edge cases, and relationship to sibling tools, leaving the agent to infer important behavior.

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 the baseline is 3. The description only echoes what the schema already states about text and messages without adding semantic detail about model defaults or input format nuances.

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?

The description clearly states the tool counts tokens for text or chat messages, and lists specific supported models. This distinguishes it from siblings like estimate_cost and list_models, which focus on cost and model enumeration.

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

Usage Guidelines3/5

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

The description implies use when token counting is needed but gives no explicit guidance on when to prefer this over estimate_cost or get_model_pricing, nor any exclusions. The context is clear, but alternatives are not addressed.

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.

TDQS

A3.9/5.0
Disambiguation5/5

Each tool has a distinct purpose: counting tokens, estimating cost, retrieving pricing, and listing models. No overlap in functionality.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern: count_tokens, estimate_cost, get_model_pricing, list_models. Clear and predictable.

Tool Count5/5

Four tools are well-scoped for a token counting and cost estimation server, covering the core needs without bloat.

Completeness4/5

The surface supports counting, cost estimation, pricing lookup, and model discovery. A minor gap is lack of batch token counting across multiple files, but core workflows are covered.