Skip to main content
Glama

ai_token_count

Read-only

Token counter and context-fit check — Estimate how many LLM tokens a text uses (GPT-4o / Claude / Llama 3 class BPE tokenizers) with a +/-15% range, plus characters, words, chars-per-token, which context windows it fits (4k to 1M), how many chunks it splits into, and an optional budget check. Query: text (required, up to 100,000 chars); optional budget= token limit to check against; optional chunk= chunk size in tokens (default 1000). Offline and instant, no model call. Price: $0.001 USDC (Base, via x402).

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": "ai_token_count"
  }
}

Input Schema

NameRequiredDescriptionDefault
textYesThe quick brown fox jumps over the lazy dog.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added

TDQS

A3.5/5.0
Behavior3/5

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

Valuable disclosure beyond the annotations: accuracy is bounded at +/-15%, the operation is offline with no model call, and it costs $0.001 USDC via x402 — the cost and precision caveats are exactly the kind of context annotations do not carry. However, 'Offline and instant, no model call' sits awkwardly against openWorldHint=true, and nothing is said about behavior when input exceeds 100,000 chars or how the +/-15% band is derived.

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

Conciseness4/5

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

Purpose is front-loaded and the rest is a compact enumeration of what comes back plus the constraints, with no filler sentences. The 'Query:' mini-spec partially duplicates the schema and the phantom budget/chunk clause adds noise, but overall the density is earning its space.

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?

With no output schema, the description correctly compensates by listing every returned field, the fitting context windows (4k to 1M), chunk splitting, and the budget check — an agent knows what to expect back. The main completeness failure is the parameter mismatch: budget and chunk are described as callable options but are absent from the schema, which undermines confidence in how to invoke it.

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?

The schema already documents the single `text` parameter at 100% coverage, so the baseline is 3. The description does add a real constraint ('up to 100,000 chars') that the schema omits, which is a genuine gain. But it also describes `budget` and `chunk` (default 1000) as if they existed, and neither appears in the input schema — an agent following the description would attempt calls that cannot succeed.

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?

The description opens with a concrete verb and resource ('Token counter and context-fit check — Estimate how many LLM tokens a text uses') and enumerates the outputs (tokens, chars, words, chars-per-token, context windows, chunks, budget). This is far more specific than a restated title. It does not, however, distinguish itself from the similarly named sibling messages_count_tokens, so an agent must infer the split.

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 context is implied rather than stated: the context-window fit list and budget check signal 'use this before sending a prompt', and 'Offline and instant, no model call' tells the agent it is safe to call freely. There is no explicit when-to-use/when-not guidance and no named alternative for the very similar messages_count_tokens tool.

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