Skip to main content
Glama

compress

Compress files or directories into ZIP archives with configurable compression levels, password protection, and encryption options.

Instructions

Compress local files or directories into a ZIP file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputYesFile path(s) or directory to compress
outputYesOutput ZIP file path
optionsNo

Implementation Reference

  • The implementation of the 'compress' tool handler which takes file/directory paths and creates a ZIP file.
    case "compress": {
      const input = args.input as string | string[];
      const output = args.output as string;
      const options = (args.options as any) || {};
    
      if (fs.existsSync(output) && !options.overwrite) {
        throw new Error(`Output file already exists: ${output}`);
      }
    
      const zip = new AdmZip();
    
      const inputs = Array.isArray(input) ? input : [input];
    
      for (const inputPath of inputs) {
        if (!fs.existsSync(inputPath)) {
          throw new Error(`Input path does not exist: ${inputPath}`);
        }
    
        const stats = fs.statSync(inputPath);
    
        if (stats.isDirectory()) {
          zip.addLocalFolder(inputPath, path.basename(inputPath));
        } else {
          zip.addLocalFile(inputPath);
        }
      }
    
      if (options.comment) {
        zip.addZipComment(options.comment);
      }
    
      zip.writeZip(output);
    
      const outputStats = fs.statSync(output);
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(
              {
                success: true,
                output: output,
                size: outputStats.size,
                files: zip.getEntries().length,
              },
              null,
              2,
            ),
          },
        ],
      };
    }
  • The schema definition for the 'compress' tool.
    {
      name: "compress",
      description: "Compress local files or directories into a ZIP file",
      inputSchema: {
        type: "object",
        properties: {
          input: {
            anyOf: [
              { type: "string" },
              { type: "array", items: { type: "string" } },
            ],
            description: "File path(s) or directory to compress",
          },
          output: {
            type: "string",
            description: "Output ZIP file path",
          },
          options: {
            type: "object",
            properties: {
              overwrite: {
                type: "boolean",
                description: "Overwrite if output file exists",
              },
              level: {
                type: "number",
                description: "Compression level (0-9)",
                minimum: 0,
                maximum: 9,
              },
              password: {
                type: "string",
                description: "Password to encrypt ZIP file",
              },
              comment: {
                type: "string",
                description: "ZIP file comment",
              },
              encryptionStrength: {
                type: "number",
                enum: [1, 2, 3],
                description:
                  "Encryption strength (1=AES-128, 2=AES-192, 3=AES-256)",
              },
            },
          },
        },
        required: ["input", "output"],
      },
    },
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. While 'compress' implies a write operation, it doesn't specify permissions needed, whether it modifies source files, error conditions, or output behavior. Some behavioral aspects like overwriting are hinted at in the schema but not in the description itself.

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?

The description is a single, efficient sentence that communicates the core functionality without unnecessary words. It's front-loaded with the essential information and contains zero wasted verbiage.

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

Completeness3/5

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

For a tool with 3 parameters, nested objects, and no output schema or annotations, the description is minimally adequate. It covers the basic purpose but lacks guidance on usage, behavioral details, and parameter explanations that would help an agent use it effectively in context.

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?

With 67% schema description coverage, the description adds minimal value beyond the schema. It mentions 'local files or directories' which aligns with the 'input' parameter, but doesn't explain the 'output' parameter or 'options' object. The schema already documents parameters well, so baseline 3 is appropriate.

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 states the action ('compress') and target ('local files or directories into a ZIP file'), making the purpose immediately understandable. It distinguishes from sibling 'decompress' by specifying compression rather than extraction, though it doesn't explicitly mention all siblings like 'getZipInfo'.

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?

No guidance is provided on when to use this tool versus alternatives like 'decompress' or 'getZipInfo'. The description only states what the tool does, not when it's appropriate or what prerequisites might be needed for successful compression.

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/loscolmebrothers/zip-mcp'

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