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
| Name | Required | Description | Default |
|---|---|---|---|
| data | Yes | The data to analyze |
Implementation Reference
- index.js:151-176 (handler)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'] } },