内容
Squoosh 命令行工具 & MCP 服务器
本仓库包含流行的Squo优化器的一个可正常运行的分支版本,特色是复活并加固的 **命令行工具** 以及全新的 **MCP(模型上下文协议)** 服务器。你可以直接从终端使用它,也可以将其插入到aude Code这样的AI工具中,让AI自动优化你的图像。
---
## 📦 全局安装(最简单的方法)
你GitHub在你的机器上全局安装命令行MCP服务器:bash
npm install -g PIMPfiction/squoosh-cli-mcp-2026
```
这将自动在你的系统上添加`squoosh-cli`和`squoosh-mcp`作为全局命令。
---
## 🤖 1. Squoosh MCP 服务器
内置的M允许AI助手(像Cl自动在你的工作流中压缩和优化图像。当被要求“优化我的图像”时,AI会连接到这个服务器并原生执行Squoosh。
### 为Claude Code安装(命令行工具)
一旦你全局安装了软件需运行以下命令即可将其连接到Claude Code:
```bash
mcp add squoosh squoosh-mcp
任何项目中打开`claude`并输入:
> _"使用squoosh压缩`src/assets/hero.jpg`文件。"_
AI将优化并更新本地HTML/文件引用。
### 为Claude
要在官方Claude桌面应用程序中使用Squoosh MCP,请CP配置文件:
- **Mac:** `~/Library/Application Support/Claude/claude_desktop_config.json`
- **Windows:** `%APPDATAaude\claude_desktop_config.json`
在你的`mcpServers`对象中添加以下内容:
```json
{
"mcpServers": {
"squoosh-mcp": {
"command": "squoosh-mcp",
"args": []
}
}
}
```
_(保存后,重启Claude Desktop)。_
---
## 🚀 2. Squoosh 命令行工具(命令行界面)
命令行工具允许你使用现代编解码器(MozJPEG、OxiPNG、WebP、AVIF、JXL)批量压缩、调整大小和优化图像。
由于你已全局安装它,你可以从任何地方运行它。
查看帮助:
```bash
squoosh-cli --help
```
### 示例压缩(MozJPEG):
将名为`test.jpg`的图像压缩到`cli/`目录中,自动进行MozJPEG优化,并在文件名后追加`_output`:
```bash
squoosh-cli test.jpg --mozjpeg auto -s _output -d cli/
```
_(注意:在回退期间,WebAssembly警告可能会暂时出现在终端中,压缩将成功)。_
---
## 👨💻 开发者注意(手动克隆)
、编辑或提交源
1. 克隆仓库:
```bash
git clone https://github.com/PIMPfiction/squoosh-cli-mcp-2026 cd squoosh-cli-m6
npm install
```
2. 直接从源代码运行:
```bash
node cli/src/prod.js --help
node squoosh-mcp.mjs
```