Skip to main content
Glama

tksq_count

Counts LLM tokens in a given text using selectable tokenizer encodings, so you can check token usage before and after manual edits.

Instructions

Count the number of LLM tokens in the given text. Supports multiple tokenizer encodings. Useful for checking token usage before and after manual edits.

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

Input Schema

NameRequiredDescriptionDefault
textYesThe text to count tokens for
tokenizerNoTokenizer encoding. cl100k_base=GPT-4/Claude (default), o200k_base=GPT-4o, approximate=fast ~4 chars/token

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.3.1

TDQS

A3.5/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. 'Count' implies a pure read-only computation with no side effects, and attention to multiple tokenizer encodings is disclosed, but there is no statement about cost, determinism, or offline execution. For a simple counting tool this is mostly adequate but not rich.

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?

Three short sentences, front-loaded with the core purpose, each contributing something. No filler or repetition.

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, pure-computation tool with complete schema documentation and no output schema, the description tells the agent everything needed to invoke it. The only minor gap is not stating that the result is the token count itself, which the name largely implies.

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 coverage is 100% and the enum values are fully documented with defaults, so the description adds little. 'Supports multiple tokenizer encodings' restates what the schema already declares without adding selection guidance beyond what the per-value descriptions provide.

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 specific verb+resource ('Count the number of LLM tokens in the given text'), making the operation unambiguous. It is clearly narrower than siblings like tksq_compress or tksq_pack, though it never explicitly contrasts itself with them.

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?

'Useful for checking token usage before and after manual edits' gives one concrete usage scenario, which is more than nothing. It offers no when-not guidance and no pointer to related tools such as tksq_compress for reducing token counts, so routing among siblings is left to inference.

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