Skip to main content
Glama
mcp-context-budget

mcp-context-budget

by yuehancn

explain_token_cost

Estimate context token cost for tool schemas or text snippets, split by CJK and ASCII, to sanity-check schemas before publishing or compare descriptions.

Instructions

Estimate the context cost of an arbitrary tool schema or text snippet, split by CJK versus ASCII. Use to sanity-check a schema before publishing a server, or to compare two descriptions.

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

Input Schema

NameRequiredDescriptionDefault
jsonNoTreat text as a JSON tool schema.
textYesRaw text or JSON to measure.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A3.8/5.0
Behavior3/5

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

No annotations are provided, so the description carries the burden. It discloses that the output is a cost estimate split by CJK versus ASCII, which is helpful, but says nothing about precision, units, model tokenizer used, or whether the read is purely local and side-effect-free.

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?

Two compact sentences with the purpose front-loaded and usage following. Nothing is wasted, though the second sentence could be tightened.

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?

For a small two-parameter read-only utility, the description covers purpose and typical use. Still missing is any notion of output units or accuracy, which matters for a cost-estimation tool with no output schema to explain results.

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 both parameters are already documented, including the json flag's meaning. The description adds only the framing of measuring arbitrary snippets, not new syntax or defaults.

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 (estimate) and resource (context cost of a tool schema or text snippet), plus the split by CJK versus ASCII. It is clearly distinct from the sibling tools, which rank servers and audit budgets rather than measuring a given snippet.

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 two concrete use cases: sanity-checking a schema before publishing a server, and comparing two descriptions. It names no explicit exclusions or alternatives, but the usage context is clear enough to select the tool.

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