Skip to main content
Glama

response_compress

Read-onlyIdempotent

Shrink oversized JSON response files to stay within size limits, using array sampling, string truncation, or key selection to return compact, inline data for your AI.

Instructions

response_compress

Reduces a JSON value inside a saved response file so it fits within the response size limit and can be returned to the LLM inline.

When to use

Use this tool after response_outline when you want to see a representative sample of a large array or reduce verbose string/object content before reading specific items.

When NOT to use

  • Do NOT use bash, cat, head, tail, file, open, less, more, or any external command to read fileRef.path.

  • Do NOT read the file manually. Always use response_compress or response_slice to access data inside saved response files.

Parameters

  • path (required): The absolute file path from fileRef.path returned by invoke.

  • jsonPath (optional): Path to the value to compress. Default is the root of the file.

  • mode (required): Compression strategy.

    • first_of_array: keep only the first element of an array.

    • sample_array: keep a head and tail sample of an array.

    • truncate_strings: shorten every string to stringLen characters.

    • keys_only: replace object values with type names.

    • select_keys: keep only the keys listed in selectKeys for every object in an array.

  • arrayHead (optional): Number of leading array items for sample_array. Default is 3.

  • arrayTail (optional): Number of trailing array items for sample_array. Default is 2.

  • stringLen (optional): Maximum string length for truncate_strings. Default is 80.

  • selectKeys (optional): Keys to keep for select_keys mode.

Returns

Either:

  • body: the compressed JSON value inline, or

  • fileRef: if the compressed result is still too large, a new saved file path and metadata.

  • hint: a short explanation of what was compressed and how to continue exploring.

After response_outline shows a large array such as pets with 5000 items:

response_compress({
  "path": "/.../responses/...json",
  "jsonPath": "pets",
  "mode": "first_of_array"
})

Then use response_slice with jsonPath like pets.0, pets.1, etc.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modeYesrequired,Compression mode: first_of_array, sample_array, truncate_strings, keys_only, select_keys
pathYesrequired,Absolute path returned in fileRef.path
jsonPathNooptional,Path to the value to compress (e.g. data or data.0)
arrayHeadNooptional,Number of leading array items for sample_array mode
arrayTailNooptional,Number of trailing array items for sample_array mode
stringLenNooptional,Maximum string length for truncate_strings mode
selectKeysNooptional,Keys to keep for select_keys mode
Behavior5/5

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

Beyond the annotations (readOnlyHint, idempotentHint), the description discloses that the tool may return either an inline body or a new fileRef if the result is still too large, and provides a hint. It also explains compression modes and default behavior, adding significant context.

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 well-structured with headers, bullet points, and a workflow example. It is slightly verbose with duplicate parameter details, but every section serves a purpose and the front-loaded summary is clear.

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

Completeness5/5

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

Without an output schema, the description fully explains return values (body, fileRef, hint) and provides a concrete workflow example. It covers all parameter semantics and mode nuances, making it self-contained for effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The parameter section goes far beyond the schema by explaining each mode's effect, providing defaults for arrayHead (3), arrayTail (2), stringLen (80), and jsonPath (root), and detailing how selectKeys works. This is critical meaning not present in the schema.

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 opens with a clear verb and resource: 'Reduces a JSON value inside a saved response file so it fits within the response size limit and can be returned to the LLM inline.' This distinguishes it from sibling tools like response_slice and response_filter by focusing on size reduction and inline return.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Contains explicit 'When to use' and 'When NOT to use' sections. It names the predecessor (response_outline) and successor (response_slice), and explicitly forbids manual file reading with external commands, directing users to this tool or response_slice instead.

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/mmadfox/swag2mcp'

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