Skip to main content
Glama

Lookup Kit

token_count

Read-only

Token counter, count LLM tokens (GPT, OpenAI tokenizer), context window check. Count tokens in a text with an offline tokenizer: OpenAI's o200k_base (the encoding of GPT-4o, GPT-4.1 and o-series models). Counts for other model families (Claude, Gemini, Llama) are estimates. Optionally checks whether it fits a limit. The text is not stored or logged. Price: $0.001 per call (x402, USDC on Base).

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

Input Schema

NameRequiredDescriptionDefault
textYes
limitNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.5/5.0
Behavior5/5

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

Goes well beyond the readOnlyHint/openWorldHint annotations: it discloses that tokenization is offline, that the input text is not stored or logged, that non-OpenAI model counts are approximations, and even the per-call price and payment rail. These are exactly the behavioral facts an agent needs before sending user text.

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?

The core purpose and encoding are front-loaded in the first two sentences, with caveats, privacy and pricing following in a logical order. The opening 'Token counter, count LLM tokens' is slightly redundant, but nothing else is wasted.

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 two-parameter utility with no output schema, the description covers the important unknowns: encoding used, estimation caveats for other models, privacy, cost, and the optional limit check. It does not describe the shape of the response (count vs. fit boolean) or the input length restriction, which are the remaining gaps.

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 0%, so the description must carry the load: it explains that `text` is the string being tokenized and that `limit` is an optional threshold for a fit check. It does not mention the 8,000-character cap on `text` or that `limit` must be a positive integer, so an agent could still trip a validation error.

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 ('count LLM tokens') plus the exact tokenizer/encoding (o200k_base, GPT-4o/4.1/o-series) and the optional limit check. An agent immediately knows this is a local tokenization utility, which no sibling tool in the catalog does.

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?

Gives clear context: use it to count tokens or to check whether text fits a context window limit. It also sets an accuracy expectation by noting that counts for Claude, Gemini and Llama are estimates. There is no explicit when-not-to-use statement or named alternative, which keeps it short of a 5.

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