ShortPixel Image Optimizer

com.shortpixel.mcp由 mcp.shortpixel.com 发布官方发布者v0.3.0更新于 Oct 24, 2026

Optimize public image URLs via the ShortPixel SPIO API for AI agents

已验证Streamable HTTP可网页运行开发者工具媒体与设计

概览

AI 生成的概览

一个远程 MCP 服务器,让助手通过 ShortPixel SPIO API 优化公开图片链接,支持压缩、缩放和格式转换等选项。

可以做什么
通过 ShortPixel 优化一个或多个公开图片链接,每次最多 100 个,返回优化后的图片地址和压缩比例。可选择压缩级别(无损、有损、光泽)、等待时间、放大倍数,以及缩放模式和目标宽高。转换格式(WebP、AVIF、JPG、PNG、GIF),移除背景,将 CMYK 转为 RGB,并保留或删除 EXIF 元数据。支持按链接单独覆盖参数,并在响应中原样回传一个数据列表。
适用场景
适合助手处理网页图片时,在对话中直接完成压缩、缩放、格式转换或背景移除。也适合每次请求批量优化最多 100 个公开图片链接。
运行要求
远程端点 mcp.shortpixel.com,使用 Streamable HTTP,最终用户无需本地安装。需要 ShortPixel 账号和 API 密钥,通过 Authorization 的 bearer 令牌(或 X-ShortPixel-Api-Key 请求头)发送。图片链接必须可公开访问。
安装前请注意
ShortPixel API 密钥会在每次请求中转发给上游 SPIO API,应作为机密保管。优化会消耗用户 ShortPixel 账户的配额或点数。服务器会把提供的图片链接发送给第三方 API。README 说明默认会记录 MCP 协议负载,但 API 密钥会被掩码处理。

安装

在 SourceWeft 中

  1. 打开 控制台中的 ShortPixel Image Optimizer,将其添加到工作区。
  2. 连接 Authorization token 凭据。它们会被私密存储,绝不会在公开页面上展示。
  3. 为需要使用其工具的对话启用该服务。

Web executable,通过 Streamable HTTP。 远程服务在工作区中配置后即可从网页运行时运行。

交给智能体安装

把这段提示词粘贴到 Claude Code、Codex、Cursor 等智能体,或 SourceWeft 对话中。智能体会读取该服务器的安装指南,先向你展示发布者、端点和登录方式,经你同意后再把它添加到你的客户端。密钥不会写进任何命令。

阅读 https://sourceweft.com/mcp/com.shortpixel.mcp%2Foptimize/install.md,并按其中说明把这个 MCP 服务器接入我的客户端。修改任何配置之前,先告诉我它的发布者、端点和登录方式,等我确认。不要把 API 密钥写进命令或我会提交的文件;问我密钥应从哪里获取。

查看智能体所依据的安装指南

其他 MCP 客户端

把它添加到你客户端的 mcpServers 配置中。

{
  "mcpServers": {
    "shortpixel-image-optimizer": {
      "type": "http",
      "url": "https://mcp.shortpixel.com/mcp",
      "headers": {
        "Authorization": "Bearer <YOUR_TOKEN>"
      }
    }
  }
}

README

ShortPixel MCP Server

Public HTTP MCP server that exposes ShortPixel SPIO image optimization to AI agents (Cursor, Claude Desktop, VS Code, etc.).

Architecture

text
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)

Each request carries the user's own ShortPixel API key. The MCP server does not store user keys — it forwards them to the public SPIO API.

Requirements

  • Node.js 20+
  • npm

Install (server)

bash
npm cinpm run buildcp .env.example .env

Edit .env for server settings (port, allowed hosts, upstream API URL). Do not put user API keys in server .env.

Run

bash
npm start

Endpoints:

PathMethodDescription
/healthGETHealth check (no API key)
/pingGETAuth check — returns ok if API key header is present
/mcpPOSTMCP Streamable HTTP endpoint

Quick test (curl)

Server up, no API key:

bash
curl http://mcp.shortpixel.com:3000/health

API key present (simple check):

bash
curl -i -H "Authorization: Bearer YOUR_API_KEY" http://mcp.shortpixel.com:3000/ping

Use http:// (not https://) on port 3000 unless TLS is configured on nginx.

MCP request (important: Streamable HTTP clients must accept both JSON and SSE):

bash
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":{}}'

Authentication

Send the user's ShortPixel API key on every MCP request:

http
Authorization: Bearer <shortpixel_api_key>

Alternative header:

http
X-ShortPixel-Api-Key: <shortpixel_api_key>

Users without a key can get one at shortpixel.com.

Cursor setup (end user)

json
{  "mcpServers": {    "shortpixel": {      "url": "https://mcp.shortpixel.com/mcp",      "headers": {        "Authorization": "Bearer YOUR_SHORTPIXEL_API_KEY"      }    }  }}

Replace the URL with your deployed host during development (e.g. http://localhost:3000/mcp).

Server environment variables

VariableRequiredDefaultDescription
PORTno3000HTTP listen port
ALLOWED_HOSTSno—Comma-separated Host header allowlist (recommended in production)
SHORTPIXEL_API_URLnohttps://api.shortpixel.com/v2Upstream SPIO API base URL
SHORTPIXEL_PLUGIN_VERSIONnoMCP01Plugin version sent to SPIO
LOG_LEVELnoinfoLog verbosity: debug, info, warn, error
LOG_FORMATnotexttext = human-readable lines; json = structured JSON
LOG_MCP_PROTOCOLnotrueLog inbound/outbound MCP JSON-RPC payloads

For internal ShortPixel development, set SHORTPIXEL_API_URL=https://devapi2.shortpixel.com/v2.

Request logging

Logs go to stdout, which the shortpixel-mcp systemd service redirects to /var/log/shortpixel/mcp.log (npm start shows them directly when running locally).

Default (LOG_FORMAT=text) — narrative flow you can follow:

[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 keeps only high-level app logs and hides MCP payload dumps.

Structured (LOG_FORMAT=json) — one JSON object per line:

EventWhen
http_requestEvery request (method, path, status, duration, MCP method/tool)
spio_requestOutgoing call to SPIO reducer.php
spio_responseSPIO result summary (status, % improvement)
mcp_auth_missingRequest without API key

API keys are masked (****abcd). Full keys are never logged.

Note: The chat prompt never reaches this server. The LLM (inside the MCP client) turns user text into a structured tools/call; the server only sees JSON-RPC arguments and maps them to the SPIO API.

bash
tail -f /var/log/shortpixel/mcp.log# or, running locallynpm start

Set LOG_LEVEL=debug for tools/list and extra HTTP lines.

Deploy

Runs as the shortpixel-mcp systemd service (unit file at /etc/systemd/system/shortpixel-mcp.service), which runs node dist/index.js directly (no pm2) and reads env vars from .env in the project directory (EnvironmentFile=).

bash
cd /web/mcp.shortpixel.com   # liveVPS; a separate host from the rest of the PHP stacknpm cinpm run build# edit .env directly on the server (not deployed - gitignored)sudo systemctl restart shortpixel-mcpsudo systemctl status shortpixel-mcp

Re-upload package.json and package-lock.json after each dependency change. If build still fails, run npm ci --include=dev (some servers set NODE_ENV=production which skips devDependencies).

Available MCP tools

ToolDescription
optimize_image_urlsOptimize one or more public image URLs via SPIO reducer API

optimize_image_urls arguments:

  • urls (required): Public image URLs to optimize (max 100)
  • lossy: Compression level (0 lossless, 1 lossy, 2 glossy)
  • wait: Max wait seconds (0 to return immediately, 1-30 to wait)
  • upscale: Upscale factor (0, 2, 3, 4)
  • resize: Resize mode (0 none, 1 outer, 3 inner, 4 smart crop)
  • resize_width, resize_height: Resize target dimensions in pixels
  • cmyk2rgb: Convert CMYK to RGB (1 yes, 0 no)
  • keep_exif: Keep EXIF metadata (1 keep, 0 remove)
  • convertto: Conversion value (+webp, +avif, +webp|+avif, webp|avif, jpg, png, gif)
  • bg_remove: Background removal (1, image URL, or #rrggbbxx)
  • refresh: Force source refetch (1) or use cached optimized data (0)
  • paramlist: Per-URL overrides array (must match urls length)
  • returndatalist: Any array echoed back unchanged in response

Project layout

text
src/index.ts                    HTTP server entry pointsrc/http/auth.ts                API key extraction from requestssrc/mcp/create-mcp-server.ts    Per-request MCP server factorysrc/clients/spio-api-client.ts  ShortPixel SPIO HTTP clientsrc/tools/spio-tools.ts         MCP toolssrc/http/request-log-middleware.ts HTTP request loggingsrc/logging/request-logger.ts    Structured JSON loggersrc/logging/mcp-protocol-log.ts  MCP protocol payload capture/normalize

Naming conventions

KindStyleExample
Fileskebab-casespio-api-client.ts
ClassesPascalCaseSpioApiClient
MethodscamelCaseoptimizeUrls

Scripts

CommandDescription
npm run buildCompile TypeScript to dist/
npm startRun HTTP MCP server
npm run devRun with tsx (no build step)

来源:README.md,提交 a7e387d

工具

0
SourceWeft 尚未读取此服务器的工具。

版本历史

1
  1. v0.3.0最新Sep 16, 2026

评分

已满足适用检查项的 75%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通必需25 分
  • 已声明认证方式必需10 分
  • 已列出工具必需15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分

    请在仓库或注册中心条目中声明许可证。