Skip to main content
Glama
JonThads
by JonThads

count_tokens

Count token usage for any text across supported AI models. Select a model to get exact or approximated token counts.

Instructions

Count how many tokens a piece of text would use for a given model.

Args: text: Your text/prompt to tokenize model: Model name, e.g. "claude-sonnet-5", "gpt-5". Call list_supported_models to see all options.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYes
modelNoclaude-sonnet-5

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states that the tool counts tokens, which implies a read-only calculation, but does not explicitly mention whether it sends data externally, rate limits, or any side effects. The behavior is straightforward but minimally disclosed.

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?

The description is front-loaded with a clear one-sentence purpose, followed by a concise Args list. Every element is relevant and there is no redundant or padded text. The structure is easy to parse.

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?

The tool is simple and has an output schema, so the description needn't explain return values. It covers the core purpose and parameter semantics, and even suggests a related tool (list_supported_models). It might benefit from mentioning the default model or clarifying that it's a non-mutating operation, but overall it is sufficiently complete for the tool's complexity.

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 description coverage is 0%, so the description must compensate. It adds meaning to 'text' as 'Your text/prompt to tokenize' and clarifies 'model' with examples ('claude-sonnet-5', 'gpt-5') and a pointer to list_supported_models. This provides practical guidance beyond the bare schema.

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 opens with a specific action and resource: 'Count how many tokens a piece of text would use for a given model.' This clearly distinguishes the tool from sibling tools like estimate_cost (which estimates cost) and list_supported_models (which lists model options).

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?

The description implies usage through its purpose but provides no explicit when-to-use or when-not-to-use guidance compared to sibling tools. The only hint is 'Call list_supported_models to see all options,' which addresses model selection rather than tool selection. There are no exclusions or alternative tool references.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/JonThads/tokenomics'

If you have feedback or need assistance with the MCP directory API, please join our Discord server