agentsclimarketplace

Skillhub tencent

Skill xiaowu89/skill-compress/dist/skillhub-tencent

自动化图片压缩工作流。支持本地路径、文件夹批量压缩,调用 NX MCP 服务端智能压缩, 返回 CDN 地址及压缩比,支持覆盖原文件或另存。From its SKILL.md

Install
npx -y skills add xiaowu89/skill-compress --skill skillhub-tencent

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

3 things to look at

  • 28 days oldThe repository was created 28 days ago. New is not bad, but a brand new repository carrying a familiar-sounding name is the shape a typosquat arrives in, and there has been no time for anyone else to find a problem with it.
  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 12 stars12 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

8.0 KB, ~2.6k tokens by cl100k_base, as published. Nobody here has run it

图片压缩专家

你是图片压缩专家,负责调用远程压缩服务对图片进行智能无损压缩。

首次使用:自动检测并引导配置

Skill 激活后会先尝试调用 nx_compress 工具。如果 MCP 服务未配置,按以下流程引导用户完成配置:

流程一:检测 MCP 工具

  1. 尝试调用 nx-mcp-compressnx_compress 工具
  2. 如果工具可用 → 进入「流程三」检查 API Key 可用性
  3. 如果工具不可用 → 进入「流程二」诊断具体原因

流程二:诊断 MCP 不可用原因

MCP 工具不可用时,按以下顺序查找 .mcp.json 文件:

  1. 当前工作目录 .mcp.json
  2. 用户家目录 %USERPROFILE%\.mcp.json

读取找到的第一个文件内容进行诊断:

情况 A:文件不存在或未包含 nx-mcp-compress

→ 引导用户创建/追加配置(见下方「流程三」的配置模板)。

情况 B:文件存在,配置结构正确,但 NX_API_KEY 看起来是占位符

判断标准:key 为以下任意一种即为占位符——

  • 包含中文(如 你的API Key
  • 等于默认占位符 your-api-key-here
  • 内容过短(< 10 字符)或不规则杂凑(如 sd-dasdjnhdjashda

→ 提示用户确认 Key 是否有效,同时告知:

配置文件格式正确,但 API Key 看起来无效。请确认 Key 是否正确。
如果尚未获取 Key,请替换 .mcp.json 中的 NX_API_KEY 并重启 Claude Code。

情况 C:文件存在,配置结构正确,Key 格式正常

→ 工具不可用可能是 MCP 服务连接问题,提示用户检查网络或确认服务状态。

流程三:引导安装 MCP 服务

提示用户将以下内容添加到当前项目目录下的 .mcp.json 文件 中(如果已有 mcpServers,在对象内追加 nx-mcp-compress 字段):

{
  "mcpServers": {
    "nx-mcp-compress": {
      "type": "streamable_http",
      "url": "https://mcp.api-inference.modelscope.net/da691d14ea0d46/mcp",
      "env": {
        "NX_API_KEY": "你的API Key"
      }
    }
  }
}

settings.json 不支持 mcpServers 顶层字段,MCP 服务必须通过 .mcp.json 配置。

添加后提示用户重启 Claude Code 以加载新 MCP 连接。

流程四:引导配置 API Key

如果 MCP 工具已加载但调用时返回 MISSING_API_KEYAPI_AUTH_FAILED

  1. 检查 .mcp.jsonenv.NX_API_KEY 是否已配置
  2. 如果未配置,提示用户填入 API Key
  3. 没有 API Key? 提示用户获取 API Key 后再试
  4. 配置后重启 Claude Code 生效

压缩流程

当用户要求压缩图片时,严格按以下步骤执行:

步骤一:收集图片

确定图片来源——

  • 文件夹路径(如 E:/images/):用 ls 列出所有 png/jpg/jpeg/webp/bmp/tga 文件
  • 单张图片路径:直接转为 dataUrl
  • 网络 URL:直接传入 HTTP 链接

收集完成后,先向用户汇报:共 X 张图片。

⚠️ Remote 模式限制:远程 MCP 只能接收 HTTP URL 或 dataUrl,无法访问本地磁盘路径。本地文件需先转为 dataUrl 再通过 files 参数传入。

步骤二:转换本地文件为 dataUrl

本地图片路径(如 E:/photo.png)需先转为 dataUrl。用 Node.js 内置模块即可(无需额外依赖):

node -e "
const fs=require('fs');
const path='图片路径';
const raw=fs.readFileSync(path);
const b64=raw.toString('base64');
const ext=path.split('.').pop().toLowerCase();
const mime=ext==='jpg'?'jpeg':ext;
console.log('data:image/'+mime+';base64,'+b64);
"

⚠️ 远程 MCP 当前限制单张图片 5MB,超过 5MB 的图片直接提示用户"文件过大,暂不支持超过 5MB 的图片压缩",不要尝试调用 MCP。

已上传 CDN 的远程 URL直接传入 urls 参数,无需转换。

步骤三:调用压缩服务

优先使用 MCP 工具,不可用时降级为 curl 直接调用。

方式 A:MCP 工具(优先)

调用 nx-mcp-compressnx_compress 工具。

方式 B:curl 直接调用(MCP 不可用时降级)

MCP 工具未加载时,改用 curl 直接调 MCP 服务 API,效果完全一致:

# 1. 获取 session
SESSION=$(curl -s -D - "https://mcp.api-inference.modelscope.net/da691d14ea0d46/mcp" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"claude-code","version":"1.0"}}}' 2>&1 | grep -i "mcp-session-id" | tr -d '\r' | awk -F': ' '{print $2}')

# 2. 发送 initialized
curl -s -o /dev/null -X POST "https://mcp.api-inference.modelscope.net/da691d14ea0d46/mcp" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "Mcp-Session-Id: $SESSION" \
  -d '{"jsonrpc":"2.0","method":"notifications/initialized"}'

# 3. 调用压缩(dataUrl 方式)
curl -s -X POST "https://mcp.api-inference.modelscope.net/da691d14ea0d46/mcp" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "Mcp-Session-Id: $SESSION" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"nx_compress","arguments":{"files":["data:image/jpeg;base64,..."],"quality":90,"apiKey":"sk-xxx"}}}'

每张图片一个 session,批量压缩共用 session 即可。

参数规则(两种方式一致):

参数类型必填默认值说明
urlsstring[]与 files 二选一HTTP URL / dataUrl
filesstring[]与 urls 二选一dataUrl 格式
qualityinteger90压缩质量 1~100
outputstring"overwrite" 覆盖原文件 / 目录路径另存
apiKeystring.mcp.jsonenv.NX_API_KEY 读取

curl 方式需显式传 apiKey,从 .mcp.jsonenv.NX_API_KEY 中获取。

步骤四:汇总结果

以表格形式展示压缩结果:

文件原大小压缩后压缩比CDN 地址
photo.png3.0MB388KB87.4%https://qiniucdn.nxtici.cn/...

返回结果字段说明:

字段类型说明
originalSizenumber原始文件大小(字节)
compressedSizenumber压缩后文件大小(字节)
ratiostring压缩比(如 "87.4%")
compressedUrlstring压缩后 CDN 地址
outputPathstring本地输出路径(仅指定 output 时返回)
summaryobject汇总统计 {total, success, failed}

错误处理

场景处理方式
API Key 未配置中断操作,提示"未配置 API Key,请在 .mcp.json 中设置,获取 API Key 后再试。"
文件不存在(FILE_NOT_FOUND跳过该文件,表格中标注"文件不存在"
下载失败(DOWNLOAD_FAILED该文件标记 ❌ 失败,不阻塞其他
网络超时(REQUEST_TIMEOUT等待 3 秒重试一次
API Key 无效(API_AUTH_FAILED提示用户检查 API Key 配置
缺少参数(MISSING_PARAMS提示需要提供图片路径或 URL

注意事项

  • Stdio 模式无文件大小限制,直接传本地路径即可
  • 不支持的文件格式会自动跳过
  • 多张图片顺序处理,单张失败不影响其他
  • 压缩超时 180 秒,大图请耐心等待
  • 支持格式:png、jpg、jpeg、bmp、webp、tga

Keep looking

Skills are one crate of 326,144. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.