Skip to main content
Glama

analyze

Analyzes data compressibility to determine optimal algorithm, compression ratio, and provide compression recommendations before processing.

Instructions

Analyze how compressible data is. Shows best algorithm, compression ratio, entropy, and recommendation. Use this before deciding whether to compress.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataYesThe data to analyze

Implementation Reference

  • The handler function that implements the "analyze" tool logic.
    handleAnalyze(args) {
      const { data } = args;
      if (!data) return { error: 'Missing "data" parameter' };
    
      const result = this.compressData(data, 'auto');
      const buf = Buffer.from(data, 'utf-8');
    
      // Estimate compressibility characteristics
      const uniqueChars = new Set(data).size;
      const entropy = this.shannonEntropy(data);
    
      return {
        original_size: buf.length,
        best_algorithm: result.algorithm,
        best_compressed_size: result.compressedSize,
        best_ratio: `${result.ratio.toFixed(1)}x`,
        all_algorithms: result.allResults,
        entropy_bits_per_char: entropy.toFixed(3),
        unique_characters: uniqueChars,
        total_characters: data.length,
        compressibility: entropy < 3 ? 'HIGH' : entropy < 5 ? 'MEDIUM' : 'LOW',
        recommendation: result.ratio > 5 ? 'Highly compressible — compress everything'
          : result.ratio > 2 ? 'Moderately compressible — compress for storage/transit'
          : 'Low compressibility — data is already dense/random'
      };
    }
  • index.js:333-343 (registration)
    Registration of the "analyze" tool with its schema definition.
    {
      name: 'analyze',
      description: 'Analyze how compressible data is. Shows best algorithm, compression ratio, entropy, and recommendation. Use this before deciding whether to compress.',
      inputSchema: {
        type: 'object',
        properties: {
          data: { type: 'string', description: 'The data to analyze' }
        },
        required: ['data']
      }
    },

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