Skip to main content
Glama

Estimate tokens and cost for a text in any measured language

estimate_text_cost

Estimate token counts and input or output costs for text on a specified model; optionally set language and message count to calculate total cost.

Instructions

Estimate how many tokens a text takes on a model and what N such messages cost as input or output, using measured tokens-per-character for its language. Detects the script if language is omitted.

Input Schema

NameRequiredDescriptionDefault
asNoinput
textYes
modelYes
languageNo
messagesNoHow many messages of this size

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

B3.4/5.0
Behavior3/5

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

With no annotations, the description carries the full burden, and it does disclose the estimation methodology (measured tokens-per-character for the language) and an automatic script-detection fallback when language is missing. It never confirms this is a side-effect-free calculation, offers no accuracy/precision caveat, and doesn't state what the response contains.

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?

Two tight sentences, front-loaded with the core action and followed by the one behavioral caveat; nothing is restated from the schema or wasted.

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

Completeness3/5

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

For a five-parameter tool with no annotations and no output schema, the definition covers intent and most parameter meaning but never describes the return shape (token count, cost, per-unit breakdown), which an agent must know since nothing structured supplies it. Adequate but with a clear gap.

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

Parameters4/5

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

Schema coverage is only 20% (just `messages` is documented), so the description has to compensate and largely does: it explains `as` as input vs output pricing, `messages` as N copies of the same text, `language` as optional with auto-detection, and `model` as the target for tokenization. The only gap is any expected format for `model` or `language` identifiers.

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

Purpose4/5

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

States a specific verb (estimate) plus the exact quantities produced (tokens and cost) and the scope ('a text ... on a model'). The phrase 'a text' implicitly differentiates it from estimate_cost, but no sibling is named, so an agent must infer the boundary from the descriptions of the others.

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

Usage Guidelines2/5

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

No explicit when-to-use or when-not-to-use guidance, and no signposting toward estimate_cost, get_model_price, or compare_models. The only conditional behavior mentioned ('Detects the script if language is omitted') is a runtime action, not guidance on selecting this tool.

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