Skip to main content
Glama

Get optimized (compressed) context

get_optimized_context

Compresses raw text or file content to fit a token budget using reversible algorithms, with auto-escalation or manual pipeline control.

Instructions

Reversible token-reduction pipeline. Accepts raw text OR a filePath. Three modes of use: (1) set targetTokens and MeshMind auto-escalates algorithms until the output fits your budget; (2) set explicit algorithms; (3) leave both for sensible defaults. Algorithms: strip, whitespace, line-dedup, json-min, truncate, stopwords, summarize. Set summarize=true for an abstractive summary via the host LLM (MCP sampling), extractive fallback. preview=true shows the per-step savings WITHOUT storing a ref. Returns compressed payload, exact BPE savings, and a ref for retrieve_context. Provide exactly one of text or filePath.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textNoRaw text/code/HTML to compress.
filePathNoLocal file to read and compress.
modeNoCompression regime (default auto).
targetTokensNoToken budget — auto-escalate the pipeline until output fits.
algorithmsNoOverride the algorithm pipeline (ignored if targetTokens set).
maxLinesNotruncate: line budget.
summarizeNoAbstractive summary via host LLM (sampling), extractive fallback.
previewNoShow per-step savings without storing a ref or recording stats.
Behavior4/5

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

No annotations provided, so the description carries full burden. It discloses reversibility, preview mode behavior (no ref stored), return values (compressed payload, BPE savings, ref), and use of MCP sampling for summarization. Missing details on error conditions or rate limits, but adequate given complexity.

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?

The description is a single dense paragraph, structuring information logically with numbered modes and algorithm list. No wasted words, though could benefit from explicit sections for readability.

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?

Without output schema, description explains return values (compressed payload, BPE savings, ref) and preview mode. Covers all 8 parameters. Lacks explicit error information but is otherwise comprehensive for a complex 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 100%, so baseline 3. The description adds value by explaining parameter interactions (e.g., targetTokens auto-escalates, algorithms ignored when targetTokens set, summarize flag behavior) beyond the schema definitions.

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 clearly states it is a 'Reversible token-reduction pipeline' that accepts raw text or a file path, distinguishing it from sibling tools like context_stats or retrieve_context.

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 explains three modes of use (targetTokens, algorithms, or both) and that exactly one of text or filePath must be provided, but does not explicitly guide when to use this tool versus siblings like crush_file or retrieve_context.

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/AntoniovanDijck/meshmind'

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