Skip to main content
Glama

Crypto, web, finance and app data tools

Token Counter & LLM Cost

token_cost

Count a text's tokens and estimate the cost of one call on popular LLMs (or the models you list), input plus an expected number of output tokens, and whether it fits each context window.

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_cost"
  }
}

Input Schema

NameRequiredDescriptionDefault
textYes
modelsNo
output_tokensNo

Output Schema

NameRequiredDescriptionDefault
resultYes

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?

No annotations exist, so the description carries the full behavioral burden. It does disclose the computational model (token count plus input and expected output cost, per model, with context-window fit), which is meaningful. It omits the tokenizer used, the cost currency/units, and which 'popular LLMs' are the default set — all of which materially affect the answer.

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?

A single dense sentence, front-loaded with the primary action ('Count a text's tokens') and then the secondary estimate. No filler, though the run-on construction with several 'and/plus' clauses takes slightly more parsing than necessary.

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

Completeness3/5

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

An output schema exists, so return values need not be explained, and all three parameters are addressed. Still, for a 3-param tool with zero annotation and zero schema-description coverage, the description should say which models are the default and how cost is denominated; those gaps affect how an agent interprets results.

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 — and it names all three parameters' roles: the text being counted, an optional list of models, and an expected output token count feeding the cost estimate. It does not specify the format for the models string (comma-separated vs. JSON) nor a currency for cost, so the compensation is good but not complete.

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?

States a specific verb+resource pair: counting tokens of a text and estimating per-call cost, plus context-window fit. An agent immediately understands the deliverable. It doesn't distinguish itself from nearby siblings such as llm_model_prices or text_stats, which keeps it from a 5.

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 use case is clearly implied (budget a prompt before calling an LLM), but there is no explicit when-to-use guidance, no statement of when llm_model_prices would be the better choice, and no note on preconditions. Adequate but leaves routing to inference.

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