Skip to main content
Glama

Estimate tokens

estimate_tokens
Read-only

Estimate the token count of text using a local heuristic, avoiding tokenizer downloads so you can gauge LLM prompt size before sending it.

Instructions

Estimate the token count of a text (fast heuristic, no tokenizer download).

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "text": "<text>"
    },
    "name": "estimate_tokens"
  }
}

Input Schema

NameRequiredDescriptionDefault
textYesThe text to measure.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A3.8/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true and openWorldHint=false, so the safety profile is covered. The description adds genuinely useful behavioral context beyond that: the result is approximate (heuristic) and requires no tokenizer download, which tells an agent how much to trust the number. It stops short of quantifying the approximation error.

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?

A single sentence with the purpose front-loaded and no wasted words; the parenthetical caveat is directly attached to the claim it qualifies.

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 one-parameter, read-only, low-complexity tool with no output schema, the description says enough: what it computes and that the result is heuristic. The only minor gap is that it doesn't state the return type or the rough accuracy, which an agent might want before relying on the figure.

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?

Only one parameter, and the schema already documents it at 100% coverage ('The text to measure.'). The description adds no syntax, length, or encoding guidance for the input, so the schema does all the work — the baseline 3 applies.

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') and resource ('token count of a text') with a parenthetical clarifying the mechanism (fast heuristic, no tokenizer download). That mechanism note distinguishes it in kind from a real tokenizer-backed counter, though it doesn't explicitly contrast with any sibling by name.

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?

Usage is only implied: the 'fast heuristic, no tokenizer download' clause hints at when this is appropriate (quick, offline-style estimation), but there is no explicit statement of when to prefer it over a precise tokenizer or when not to rely on it. No alternatives are named.

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