Skip to main content
Glama

compress

Compress text, JSON, or CSV data to reduce size and optimize storage. Automatically selects the best compression algorithm and returns base64-encoded results with compression ratio.

Instructions

Compress text/JSON/CSV data. Returns base64-encoded compressed data with compression ratio. Use algorithm="auto" to pick the best compression.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataYesThe data to compress (text, JSON, CSV, etc.)
algorithmNoCompression algorithm. Default: auto (picks best)

Implementation Reference

  • The handler function for the 'compress' tool, which processes input data using chosen compression algorithms and returns statistics.
    handleCompress(args) {
      const { data, algorithm = 'auto' } = args;
      if (!data) return { error: 'Missing "data" parameter' };
    
      const result = this.compressData(data, algorithm);
      this.stats.total_compressed++;
      this.stats.total_saved_bytes += result.originalSize - result.compressedSize;
      this.stats.operations++;
    
      return {
        compressed_base64: result.compressed.toString('base64'),
        algorithm: result.algorithm,
        original_size: result.originalSize,
        compressed_size: result.compressedSize,
        ratio: `${result.ratio.toFixed(1)}x`,
        saved_bytes: result.originalSize - result.compressedSize,
        saved_percent: `${((1 - result.compressedSize / result.originalSize) * 100).toFixed(1)}%`,
        ...(result.allResults ? { all_algorithms: result.allResults } : {})
      };
    }
  • The tool registration schema for 'compress', defining its input parameters and functionality description.
    {
      name: 'compress',
      description: 'Compress text/JSON/CSV data. Returns base64-encoded compressed data with compression ratio. Use algorithm="auto" to pick the best compression.',
      inputSchema: {
        type: 'object',
        properties: {
          data: { type: 'string', description: 'The data to compress (text, JSON, CSV, etc.)' },
          algorithm: { type: 'string', enum: ['auto', 'gzip', 'brotli', 'deflate'], description: 'Compression algorithm. Default: auto (picks best)' }
        },
        required: ['data']
      }
    },
Behavior3/5

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

With no annotations provided, the description must carry full behavioral disclosure. It successfully explains the output encoding (base64) and metadata inclusion (compression ratio), but omits safety information, side effects, idempotency, or limits regarding input data size.

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 sentences efficiently deliver the core purpose, return value specification, and usage tip. No wasted words; information is appropriately front-loaded with the primary function stated immediately.

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?

Despite the absence of an output schema, the description adequately compensates by detailing the return value structure. For a tool with only two parameters (both well-documented in schema) and simple behavior, the description provides sufficient context, though error conditions or input size limits are not addressed.

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%, establishing a baseline of 3. The description lists supported data formats and mentions the auto algorithm, but this largely restates information already present in the JSON schema property descriptions without adding additional semantic context.

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?

The description clearly identifies the action (Compress) and supported resource types (text/JSON/CSV data), and specifies the return format (base64-encoded data with compression ratio). However, it does not explicitly differentiate from the 'decompress' sibling tool despite the complementary relationship.

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

Usage Guidelines2/5

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

While the description provides parameter-level guidance ( recommending algorithm='auto'), it offers no tool-level guidance on when to use compression versus alternatives like 'decompress', 'analyze', or 'store' for data management decisions.

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/ShipItAndPray/mcp-compress'

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