Skip to main content
Glama

Compress prompt

compress_prompt
Read-only

Compress prompts, system prompts, or context blocks to reduce token usage with deterministic rule-based processing that preserves template variables and returns token stats.

Instructions

Compress a prompt, system prompt, or context block to use fewer tokens, using deterministic rule-based algorithms (no LLM call). Template variables like {{name}} and {var} are preserved. Returns the compressed text and token stats.

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

Input Schema

NameRequiredDescriptionDefault
textYesThe text to compress.
levelNoRisk level. 'none' = whitespace/unicode only; 'very-low' = + filler, phrases, JSON/SQL minify; 'low' = + hedging, comments, dedup (recommended); 'medium' = + extractive summarization (may drop sentences).low

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A3.9/5.0
Behavior4/5

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

Goes beyond the readOnlyHint/openWorldHint annotations by disclosing that compression is deterministic and rule-based with no LLM call, and that {{name}}/{var} template variables survive compression. It also states what comes back (compressed text plus token stats). Minor gap: it does not say whether the transformation is lossless at each level, though the schema notes 'medium' may drop sentences.

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?

Three short sentences, front-loaded with what it does, then the mechanism, then the preservation guarantee and return shape. No filler and nothing repeated from the schema.

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?

With no output schema available, the description usefully summarizes the return value and states the key behavioral constraint (no LLM call). The only omission is detail on what the token stats contain, which is minor for a two-parameter read-only tool.

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 coverage is already 100% with a fully documented enum, so the baseline is 3. The description earns above that by adding a guarantee about the 'text' parameter not covered by the schema: template variables in the input are preserved through compression.

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 (compress) plus the resource domain (prompt, system prompt, or context block) and states the goal of using fewer tokens. It does not differentiate itself from the sibling compress_file, which handles files rather than inline text, so an agent must infer that boundary.

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 input domain implies when to use it (inline text/prompt content), but there is no explicit when-not or pointer to siblings like compress_file or estimate_tokens. The guidance about choosing a 'level' lives in the schema, not the description.

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