Skip to main content
Glama

count_tokens

Read-onlyIdempotent

Count tokens in UTF-8 text using Algenta tokenizer models for prompt-size checks and token budgeting. Deterministic and read-only; returns token count and resolved model details.

Instructions

Count how many tokens a supported deterministic Algenta tokenizer model produces for UTF-8 text (default text.tokenizer; call list_models for every supported model id). Use this for prompt-size checks and token budgeting; call tokenize when you also need the token strings. Read-only and deterministic: the same input and model always return the same count, and nothing is stored. Returns the resolved model id, its tokenizer_kind, and token_count. An unsupported model id fails with model_not_supported.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputYesUTF-8 text whose tokens are counted.
modelNoTokenizer model id from list_models.text.tokenizer

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.1.3
    • addedInput schema / properties / input / description
      Added value: +"UTF-8 text whose tokens are counted."
    • addedInput schema / properties / model / description
      Added value: +"Tokenizer model id from list_models."
  2. First observedv0.1.0

TDQS

A4.7/5.0
Behavior5/5

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

Annotations already declare read-only, idempotent, and non-destructive behavior. The description adds valuable context beyond those: determinism, that nothing is stored, the returned fields, and the error behavior for unsupported model ids. This is robust behavioral disclosure especially with no output schema present.

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?

Every sentence earns its place: purpose, usage, behavioral guarantees, return shape, and error condition are all covered without fluff. The most important scoping information is front-loaded in the first sentence.

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

Completeness5/5

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

For a simple two-parameter read-only tool, the description is fully complete. It explains what is returned, how to discover valid model ids, when to use tokenize instead, and what happens on invalid input. No essential calling information is missing.

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 description coverage is 100%, so the schema already documents both parameters and their roles. The description adds minor value by naming the default model id and pointing to list_models, but most parameter meaning is already in the schema. Baseline 3 is appropriate.

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?

The description uses a specific verb and resource: 'Count how many tokens a supported deterministic Algenta tokenizer model produces for UTF-8 text.' It also distinguishes itself from the sibling tool tokenize by noting that tokenize is for when token strings are also needed. This makes the tool's purpose immediately clear and differentiated.

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

Usage Guidelines5/5

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

It explicitly says when to use the tool ('Use this for prompt-size checks and token budgeting') and when to use an alternative ('call tokenize when you also need the token strings'). It also instructs the agent to call list_models for supported model ids, which fully covers usage context.

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

Deploy Server

Other Tools