ShortPixel MCP Server
OfficialShortPixel MCP 服务器
面向 AI 代理(Cursor、Claude Desktop、VS Code 等)公开 ShortPixel SPIO 图像优化功能的公共 HTTP MCP 服务器。
架构
AI client (Cursor, Claude, …)
│
│ MCP over HTTPS (Streamable HTTP)
▼
https://mcp.shortpixel.com/mcp
│
│ user's API key in Authorization header
▼
ShortPixel SPIO API (api.shortpixel.com)每个请求携带用户自己的 ShortPixel API 密钥。MCP 服务器不存储用户密钥——而是将其转发到公共 SPIO API。
Related MCP server: img-convert MCP Server
要求
Node.js 20+
npm
安装(服务器)
npm ci
npm run build
cp .env.example .env编辑 .env 以配置服务器设置(端口、允许的主机、上游 API URL)。不要将用户 API 密钥放入服务器 .env 中。
运行
npm start端点:
路径 | 方法 | 描述 |
| GET | 健康检查(无需 API 密钥) |
| GET | 认证检查——如果存在 API 密钥头则返回 ok |
| POST | MCP 流式 HTTP 端点 |
快速测试(curl)
服务器启动,无 API 密钥:
curl http://mcp.shortpixel.com:3000/health存在 API 密钥(简单检查):
curl -i -H "Authorization: Bearer YOUR_API_KEY" http://mcp.shortpixel.com:3000/ping使用 http://(而非 https://)和端口 3000,除非在 nginx 上配置了 TLS。
MCP 请求(重要:流式 HTTP 客户端必须同时接受 JSON 和 SSE):
curl -s -N -X POST http://mcp.shortpixel.com:3000/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'认证
在每个 MCP 请求中发送用户的 ShortPixel API 密钥:
Authorization: Bearer <shortpixel_api_key>备选头:
X-ShortPixel-Api-Key: <shortpixel_api_key>没有密钥的用户可以在 shortpixel.com 获取一个。
Cursor 设置(最终用户)
{
"mcpServers": {
"shortpixel": {
"url": "https://mcp.shortpixel.com/mcp",
"headers": {
"Authorization": "Bearer YOUR_SHORTPIXEL_API_KEY"
}
}
}
}开发期间将 URL 替换为你的部署主机(例如 http://localhost:3000/mcp)。
服务器环境变量
变量 | 必需 | 默认值 | 描述 |
| 否 |
| HTTP 监听端口 |
| 否 | — | 逗号分隔的 Host 头允许列表(生产环境推荐) |
| 否 |
| 上游 SPIO API 基础 URL |
| 否 |
| 发送给 SPIO 的插件版本 |
| 否 |
| 日志详细程度: |
| 否 |
|
|
| 否 |
| 记录入站/出站 MCP JSON-RPC 负载 |
对于内部 ShortPixel 开发,设置 SHORTPIXEL_API_URL=https://devapi2.shortpixel.com/v2。
请求日志
日志输出到 stdout(pm2 logs / npm start)。
默认(LOG_FORMAT=text)——可追踪的叙述流:
[2026-06-30 15:01:53] [1/5] → CLIENT | HTTP POST /mcp | JSON-RPC request: "initialize" (client connects) | id: 0
{
"jsonrpc": "2.0",
"method": "initialize",
"id": 0,
"params": { ... }
}
[2026-06-30 15:01:53] [1/5] ← SERVER | HTTP POST /mcp 200 | JSON-RPC response: "initialize" (client connects)
[2026-06-30 15:01:53] [2/5] → CLIENT | HTTP POST /mcp | JSON-RPC request: "notifications/initialized" (session ready, no response body expected) | id: null
[2026-06-30 15:01:53] [2.5/5] → CLIENT | HTTP POST /mcp | JSON-RPC request: "tools/list" (client asks which tools exist) | id: 1
[2026-06-30 15:01:53] [2.5/5] ← SERVER | HTTP POST /mcp 200 | JSON-RPC response: "tools/list" (client asks which tools exist) | tools discovered: optimize_image_urls
[2026-06-30 15:02:18] [3/5] → CLIENT | HTTP POST /mcp | JSON-RPC request: "tools/call" (client runs a tool) | id: 2 | tool: "optimize_image_urls"
[2026-06-30 15:02:18] [4/5] MCP → SPIO API: POST reducer.php (args mapped to SPIO payload) | ...
[2026-06-30 15:02:35] [5/5] MCP ← SPIO API: Success | reduction: 27.41% | optimized: http://api.shortpixel.com/f/...-lossy.jpg | original: ...
[2026-06-30 15:02:35] [3/5] ← SERVER | HTTP POST /mcp 200 | JSON-RPC response: "tools/call" (client runs a tool) | tool: optimize_image_urls
{ "jsonrpc": "2.0", "id": 2, "result": { ... } }
[2026-06-30 15:02:35] ✓ round-trip done (16.3s)LOG_MCP_PROTOCOL=false 仅保留高级应用日志,隐藏 MCP 负载转储。
结构化(LOG_FORMAT=json)——每行一个 JSON 对象:
事件 | 触发时机 |
| 每个请求(方法、路径、状态、耗时、MCP 方法/工具) |
| 对 SPIO |
| SPIO 结果摘要(状态、改进百分比) |
| 无 API 密钥的请求 |
API 密钥被屏蔽(****abcd)。完整密钥永远不会被记录。
注意: 聊天提示永远不会到达此服务器。LLM(在 MCP 客户端内部)将用户文本转换为结构化的 tools/call;服务器仅看到 JSON-RPC 参数并将其映射到 SPIO API。
pm2 logs shortpixel-mcp
# or
npm start设置 LOG_LEVEL=debug 以查看 tools/list 和额外的 HTTP 行。
在开发服务器上部署
cd /xxx/mcp.shortpixel.com
npm ci
npm run build
cp .env.example .env
# set ALLOWED_HOSTS and PORT, then run behind nginx with TLS
npm start每次依赖变更后重新上传 package.json 和 package-lock.json。如果构建仍然失败,运行 npm ci --include=dev(某些服务器设置了 NODE_ENV=production,会跳过 devDependencies)。
可用的 MCP 工具
工具 | 描述 |
| 通过 SPIO reducer API 优化一个或多个公共图片 URL |
optimize_image_urls 参数:
urls(必需):要优化的公共图片 URL(最多 100 个)lossy:压缩级别(0无损,1有损,2光泽)wait:最大等待秒数(0立即返回,1-30等待)upscale:放大倍数(0、2、3、4)resize:调整大小模式(0无,1外切,3内切,4智能裁剪)resize_width、resize_height:调整大小的目标像素尺寸cmyk2rgb:将 CMYK 转换为 RGB(1是,0否)keep_exif:保留 EXIF 元数据(1保留,0移除)convertto:转换值(+webp、+avif、+webp|+avif、webp|avif、jpg、png、gif)bg_remove:背景移除(1、图片 URL 或#rrggbbxx)refresh:强制重新获取源(1)或使用缓存的优化数据(0)paramlist:每个 URL 的覆盖数组(必须与urls长度匹配)returndatalist:任何数组,在响应中原样返回
项目布局
src/index.ts HTTP server entry point
src/http/auth.ts API key extraction from requests
src/mcp/create-mcp-server.ts Per-request MCP server factory
src/clients/spio-api-client.ts ShortPixel SPIO HTTP client
src/tools/spio-tools.ts MCP tools
src/http/request-log-middleware.ts HTTP request logging
src/logging/request-logger.ts Structured JSON logger
src/logging/mcp-protocol-log.ts MCP protocol payload capture/normalize命名约定
种类 | 风格 | 示例 |
文件 | kebab-case |
|
类 | PascalCase |
|
方法 | camelCase |
|
脚本
命令 | 描述 |
| 将 TypeScript 编译到 |
| 运行 HTTP MCP 服务器 |
| 使用 tsx 运行(无需构建步骤) |
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables AI assistants to download images from URLs and perform basic image optimization tasks.21818Apache 2.0
- Alicense-qualityDmaintenanceProvides AI agents with tools to convert images between formats and inspect image metadata, enabling seamless image processing within agent workflows.83MIT

@metricspot/mcp-serverofficial
Alicense-qualityFmaintenanceExposes SEO and AI-readability audit tools to AI agents, enabling one-shot anonymous audits or full authenticated audits with PDF reports and organic traffic data.66MIT- FlicenseAqualityDmaintenanceExposes the OctoBoost SEO API as MCP tools so agents can audit websites with compact, structured results instead of fetching and parsing raw HTML.486
Related MCP Connectors
SEO research, audits, backlinks, GSC, and content workflow tools for AI agents.
Zero-auth MCP: image optimize, cited storage/format data, and dev utilities LLMs get wrong.
URL intelligence for AI agents and developers. 16 tools, 25 signal weights, 20 free checks.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/short-pixel-optimizer/com.shortpixel.mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server