Skip to main content
Glama

Truncate to token budget

truncate_to_budget
Read-onlyIdempotent

Truncate text to max_tokens (keep start or end) for an encoding or model.

Input Schema

NameRequiredDescriptionDefault
keepNo
textYesText (≤256 KB). URLs are not fetched.
modelNo
encodingNo
max_tokensYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A3.5/5.0
Behavior3/5

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

Annotations already declare readOnly, idempotent, non-destructive and closed-world, so safety needs no restatement. The description adds nothing about whether a marker is inserted, what the default keep direction is, or how encoding/model precedence is resolved, which matters for an operation that silently discards content.

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 with the action and constraints front-loaded and no filler. The compression is slightly at the cost of clarity around the encoding/model pairing.

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?

Given four safety annotations and no output schema, the definition covers the essentials for a simple pure-transform tool. Remaining gaps (return value shape, default keep direction, tokenizer precedence) are modest but real for a 5-parameter tool at 20% schema coverage.

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 only 20% (only 'text' documented), yet the description does cover max_tokens, the start/end choice, and the encoding-or-model tokenizer notion, adding real meaning beyond the schema for three of five parameters. It still leaves 'model' vs 'encoding' precedence and the default for 'keep' unstated.

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?

Names a specific verb (truncate) and resource (text) plus the governing constraint (max_tokens) and the keep-direction option, so an agent can distinguish it from count_tokens or chunk_text. It stops short of explicitly stating how it differs from the chunking sibling.

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 phrase 'for an encoding or model' implies the situation (fitting text into a token budget under a specific tokenizer) but there is no explicit when-to-use, when-not, or named alternative such as chunk_text for cases where content must be preserved rather than cut.

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