Skip to main content
Glama
Qiuerjun

mcp-7zip-server

by Qiuerjun

MCP 7-Zip Server

⚠️ 注意:本项目为个人练手项目,目前暂时无法使用,仅供学习参考。

npm version License: MIT Node.js Version MCP Compatible

一个基于 Model Context Protocol (MCP) 的 7-Zip 压缩文件操作服务器,采用双引擎架构设计。本项目为个人学习 MCP 协议开发的练手作品,尚未完成全部功能验证,暂时无法正常使用。

✨ 核心特性

  • 🔄 双引擎架构:同时支持内置打包引擎和系统本地引擎

  • 🛡️ 安全沙盒:解压操作限制在安全目录,防止路径遍历攻击

  • 📦 多格式支持:7z, zip, rar, tar, gz, bz2, xz 等主流格式

  • 🔐 密码支持:支持加密压缩和解压

  • 智能探测:自动检测并选择可用的 7-Zip 引擎

Related MCP server: mcp-tmpfs-server

🚀 快速开始

模式 A:开箱即用版(推荐小白)

由于使用了 optionalDependencies,默认 npx 会自动下载并使用内置的 7-Zip 引擎,无需额外配置。

Claude Desktop 配置 (~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json):

{
  "mcpServers": {
    "7zip": {
      "command": "npx",
      "args": ["-y", "mcp-7zip-server"]
    }
  }
}

Cursor 配置 (.cursor/mcp.json):

{
  "mcpServers": {
    "7zip": {
      "command": "npx",
      "args": ["-y", "mcp-7zip-server"]
    }
  }
}

模式 B:轻量化极速版(推荐极客)

如果你已经安装了系统 7-Zip,可以跳过下载内置引擎,使用更轻量的安装方式:

npm install -g mcp-7zip-server --no-optional

Claude Desktop 配置:

{
  "mcpServers": {
    "7zip": {
      "command": "mcp-7zip-server",
      "env": {
        "USE_SYSTEM_7ZIP": "true"
      }
    }
  }
}

Cursor 配置:

{
  "mcpServers": {
    "7zip": {
      "command": "mcp-7zip-server",
      "env": {
        "USE_SYSTEM_7ZIP": "true"
      }
    }
  }
}

📋 环境变量

环境变量

说明

默认值

示例

SEVEN_ZIP_PATH

手动指定 7-Zip 可执行文件的绝对路径

-

/usr/local/bin/7zC:\Program Files\7-Zip\7z.exe

USE_SYSTEM_7ZIP

强制使用系统安装的 7-Zip

false

true1

MCP_7ZIP_SANDBOX

自定义沙盒目录路径

~/.mcp-7zip-sandbox

/path/to/sandbox

引擎优先级

服务器按以下优先级选择 7-Zip 引擎:

  1. 最高优先级SEVEN_ZIP_PATH 环境变量指定的路径

  2. 次高优先级USE_SYSTEM_7ZIP=true 强制使用系统 7-Zip

  3. 默认行为:尝试内置引擎 → 降级到系统 7-Zip

🔧 MCP Tools

list_archive

列出压缩文件中的内容。

参数:

  • archivePath (必填):压缩文件的绝对路径

  • password (可选):解压密码

示例:

{
  "archivePath": "/path/to/archive.7z"
}

extract_archive

解压文件到沙盒目录。

参数:

  • archivePath (必填):压缩文件的绝对路径

  • targetDir (可选):解压目标目录(相对于沙盒目录)

  • password (可选):解压密码

  • overwrite (可选):覆盖策略 - overwrite(默认)、skiprename

示例:

{
  "archivePath": "/path/to/archive.zip",
  "targetDir": "my-extracted-files",
  "overwrite": "skip"
}

create_archive

创建压缩文件。

参数:

  • archivePath (必填):输出压缩文件的路径

  • files (必填):要压缩的文件/目录路径列表

  • format (可选):压缩格式 - 7z(默认)、ziptargzbz2xz

  • password (可选):加密密码

  • compressionLevel (可选):压缩级别 0-9(默认 5)

示例:

{
  "archivePath": "/path/to/output.7z",
  "files": ["/path/to/file1.txt", "/path/to/folder"],
  "format": "7z",
  "compressionLevel": 9
}

🛡️ 安全特性

防命令注入

  • 使用 execFile 而非 exec,参数以数组形式传递

  • 不使用 shell 执行,防止命令注入攻击

防路径遍历(沙盒机制)

  • 解压操作强制限制在沙盒目录(默认 ~/.mcp-7zip-sandbox

  • 压缩时校验输入路径,禁止读取 /etc~/.ssh 等敏感目录

  • 可通过 MCP_7ZIP_SANDBOX 环境变量自定义沙盒位置

防上下文爆炸

  • list_archive 输出超过 4000 字符自动截断

  • 截断时显示文件总数统计,提示使用过滤条件

📦 支持的格式

格式

读取

写入

说明

7z

高压缩比,推荐

zip

通用兼容

rar

只读支持

tar

Unix 归档

gz

gzip 压缩

bz2

bzip2 压缩

xz

xz 压缩

🔍 故障排除

"未找到 7-Zip 引擎" 错误

解决方案(任选其一):

  1. 安装系统 7-Zip

  2. 重新安装内置引擎

    npm install -g mcp-7zip-server
  3. 手动指定路径

    {
      "env": {
        "SEVEN_ZIP_PATH": "/path/to/7z"
      }
    }

权限问题

如果遇到权限错误,确保沙盒目录有写入权限:

mkdir -p ~/.mcp-7zip-sandbox
chmod 755 ~/.mcp-7zip-sandbox

🏗️ 开发

# 克隆仓库
git clone https://github.com/your-username/mcp-7zip-server.git
cd mcp-7zip-server

# 安装依赖
npm install

# 开发模式(监听文件变化)
npm run dev

# 构建
npm run build

# 运行
npm start

📄 许可证

MIT License - 详见 LICENSE 文件

🤝 贡献

欢迎提交 Issue 和 Pull Request!

🙏 致谢

Available Tools

3 tools
create_archiveB

创建压缩文件(支持 7z, zip, tar, gz, bz2, xz 格式)

ParametersJSON Schema
NameRequiredDescriptionDefault
archivePathYes输出压缩文件的路径
filesYes要压缩的文件/目录路径列表
formatNo压缩格式7z
passwordNo加密密码
compressionLevelNo压缩级别 (0-9)

TDQS

B3.3/5.0
Behavior2/5

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

With no annotations, the description carries the full burden. It only mentions supported formats and does not disclose behaviors like overwriting, permissions, or performance implications.

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 a single sentence that concisely states the core action. However, it could be slightly expanded with usage notes without losing conciseness.

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

Completeness2/5

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

No output schema, and the description does not explain return values, error handling, or side effects. For a 5-parameter tool, this is insufficient.

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%, so baseline is 3. The description adds no extra meaning beyond the schema's parameter descriptions; it merely repeats the format list already present in the enum.

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 clearly states the action ('创建压缩文件' meaning 'create compressed file') and the resource (archive), and lists supported formats (7z, zip, tar, gz, bz2, xz), which distinguishes it from sibling tools 'extract_archive' and 'list_archive'.

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

Usage Guidelines3/5

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

Usage is implied by the description ('create compressed file') and the context of sibling tools, but no explicit when-to-use or when-not-to-use guidance is provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

extract_archiveB

解压文件到指定目录(默认解压到沙盒目录)

ParametersJSON Schema
NameRequiredDescriptionDefault
archivePathYes压缩文件的绝对路径
targetDirNo解压目标目录(相对于沙盒目录)
passwordNo解压密码(如果加密)
overwriteNo文件覆盖策略overwrite

TDQS

B3.2/5.0
Behavior2/5

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

With no annotations provided, the description carries the full burden for behavioral traits. It mentions only the default sandbox directory. It does not disclose side effects, supported archive formats, error handling, or other important behaviors beyond what the schema already indicates.

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, concise sentence with no redundancy. It is front-loaded with the core action and resource, earning its place without waste.

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

Completeness2/5

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

Given 4 parameters, no output schema, and no annotations, the description is insufficient. It lacks details on return values, error conditions, or specific usage scenarios. The default behavior is noted, but overall completeness is low for a tool with multiple options.

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%, so baseline is 3. The description adds minimal value beyond the schema (only mentioning default target directory). It does not provide additional context for parameters like password or overwrite policies.

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 clearly states the tool's purpose: extract files to a specified directory. It uses a specific verb (extract) and resource (archive), and distinguishes from sibling tools (create_archive, list_archive) which perform different operations.

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 on when to use this tool versus alternatives. The description does not provide context for when extraction is appropriate or mention any prerequisites. There are no explicit exclusions or comparisons to sibling tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_archiveB

列出压缩文件中的内容(支持 7z, zip, rar, tar, gz 等格式)

ParametersJSON Schema
NameRequiredDescriptionDefault
archivePathYes压缩文件的绝对路径
passwordNo解压密码(如果加密)

TDQS

B3.3/5.0
Behavior2/5

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

No annotations provided; description carries full burden. It does not disclose whether the operation is destructive (likely not), authentication needs, or performance implications. It only says 'list contents' without clarifying behavior like temporary extraction or metadata detail.

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?

Single sentence that front-loads the purpose. No unnecessary words; every part earns its place.

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?

Tool is simple with two parameters and no output schema. Description covers supported formats and basic action, but lacks information about return value structure, error behavior, or password handling nuances.

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% with clear parameter descriptions. The tool description adds no additional meaning beyond what the schema already provides.

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?

Clearly states the verb 'list' and resource 'contents of compressed files', and explicitly lists supported formats (7z, zip, rar, tar, gz), distinguishing it from sibling tools create_archive and extract_archive.

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 on when to use or when not to use. No mention of alternatives or exclusions. The description only states the function without contextual usage advice.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 3 tool updatesv1.0.0
    • First observedcreate_archive
    • First observedextract_archive
    • First observedlist_archive

TDQS

A3.6/5.0
Disambiguation5/5

Each tool has a distinct purpose: creating, extracting, and listing archives. No overlap or ambiguity.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern: create_archive, extract_archive, list_archive.

Tool Count4/5

3 tools cover the core archiving operations. The count is slightly low for a full-featured server but appropriate for a focused utility.

Completeness3/5

Basic create, extract, and list are covered, but update and delete operations are missing, which are common in an archiving context.

Maintenance

ActivityInactive
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    A local MCP server that provides tools for working with 7-Zip archives, enabling archive creation, extraction, item management, and file system operations through a standardized interface.
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    MCP server that exposes file operations (list, read, write, delete, unzip) in a sandbox directory, preventing path traversal.
    14
    MIT

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

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