Skip to main content
Glama

easytiny-mcp

视觉无损的图片批量压缩 MCP 服务。压缩结果先放在临时目录预览,用户确认后才原地替换原图。

工具

工具

作用

prepare_compression

压缩到临时目录,返回 plan_id 和预览表(原大小、新大小、编码器、SSIMULACRA2 分数、跳过原因)

apply_compression

用户在聊天中确认后,传入 plan_id 和必填的 confirmed: true 原子替换原图,不再发起额外确认表单,可选 backup

cancel_compression

丢弃预览结果

Related MCP server: TinyPNG MCP Server

确认与替换流程

  1. 调用 prepare_compression,将返回的预览表完整展示给用户,原图保持不变。

  2. 用户在聊天中明确同意替换该计划后,调用 apply_compression({ plan_id, confirmed: true });需要备份时额外传入 backup: true。

  3. 服务端校验确认参数和计划,再检查原图是否发生变化并执行替换。无论客户端是否支持 elicitation,都不会再次请求确认表单。

confirmed 无默认值:省略、传 false 或传字符串 "true" 都不会替换文件,计划仍可在有效期内重新提交。计划有效期为 30 分钟,失效或服务重启后需要重新生成预览并获得确认。

此参数是调用方对已有用户授权的明确声明;服务端能校验参数,不能直接读取或验证聊天内容。调用方必须确认授权对应当前 plan_id,不得自行填 true。客户端自身的工具审批策略仍然生效。

升级时,原先只传 { plan_id } 的调用及工作流说明需同步增加 confirmed: true(仅在用户已同意后)。已运行的 MCP 服务需重启或重新连接以加载新的工具定义;固定使用 npm 旧版本的配置不会自动使用本地修改。

压缩策略

每种格式一个主力编码器,按固定顺序尝试,采用第一个「节省 ≥3% 且 SSIMULACRA2 ≥85」的结果,最后以无损优化兜底。小于 10KB 或已压缩过的文件直接跳过。

格式

balanced 尝试顺序

JPEG

cjpegli -d 1.0 → -d 0.7 → jpegtran 无损;原图质量 ≤75 只做无损

PNG

pngquant 80-98 → 截低位 4 → 截低位 2 → oxipng 无损(有损结果都会再过 oxipng)

WebP

有损源 cwebp -q 90 → -q 93;无损源 near_lossless 60 → 无损

AVIF

avifenc -q 74 -s 6 tune=iq

GIF

gifsicle -O3 --lossy=40 → -O3 无损

SVG

SVGO(保守配置)+ 渲染比对

effort:fast 跳过 SSIMULACRA2 判定、参数更保守;max 从更激进的参数逐级放宽,更慢、压缩率更高。

开发

pnpm install
scripts/build-bins.sh         # 编译编码器到 vendor/bin(也可用 EASYTINY_BIN_DIR 指定目录)
pnpm tsx scripts/gen-img.ts   # 重新生成 img/ 下的测试图片(已提交,一般无需运行)
pnpm fixtures                 # 从 img/ 生成其他格式的测试样例
pnpm bench img bench/fixtures [--effort fast|balanced|max] [-v]   # 只输出统计,不改动原图
pnpm test

接入

支持 macOS(Apple Silicon / Intel)与 Windows x64,需要 Node.js ≥ 20。编码器随平台包自动安装,无需额外依赖。

# Claude Code:所有项目可用;只想在当前项目用就去掉 --scope user
claude mcp add --scope user easytiny -- npx -y easytiny-mcp

其他客户端(Cursor 等)的 JSON 配置:

{ "mcpServers": { "easytiny": { "command": "npx", "args": ["-y", "easytiny-mcp"] } } }

本地开发版:先 pnpm build,再把命令换成 node /path/to/easytiny-mcp/dist/index.js。

发布

推送 v* tag 后,GitHub Actions 会在各平台编译编码器、跑测试,并发布主包 easytiny-mcp 与平台包 easytiny-mcp-darwin-arm64、easytiny-mcp-darwin-x64、@easychan/easytiny-mcp-win32-x64:

git tag v0.2.0 && git push origin v0.2.0

npm 认证使用 Trusted Publishing(OIDC),无需长期 token:

  1. 首次发布前包还不存在,需要在 npm 生成一个可发布的 Granular Access Token,填入仓库 Secrets 的 NPM_TOKEN。

  2. 首次发布成功后,在 npmjs.com 上为 4 个包分别添加 Trusted Publisher(仓库 chaneasy/easytiny-mcp,工作流 release.yml,环境 npm),然后删除 NPM_TOKEN。

Available Tools

3 tools
apply_compression替换原图A
Destructive

用 prepare_compression 的结果替换原图。只能在用户看过预览表并明确同意后调用。

NameRequiredDescriptionDefault
backupNo替换前把原图备份到同目录的 .image-backup/
plan_idYesprepare_compression 返回的 plan_id

TDQS

A4.4/5.0
Behavior4/5

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

Annotations already declare destructiveHint=true, so the description does not need to argue that this mutates state. It still adds real value by disclosing the human-in-the-loop consent requirement, which annotations cannot express. It stops short of stating that the replacement is irreversible or what happens if backup is left at its default false, which would complete the picture.

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?

Two short sentences: the action first, the safety gate second. Nothing is padded and no sentence restates the tool name or annotations.

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

Completeness4/5

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

For a destructive, two-parameter mutation tool, the description covers the action, the upstream dependency, and the consent gate, with annotations handling the destruction signal. A note on irreversibility or on the consequence of the default backup=false would make it fully self-sufficient.

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 backup's default false and backup directory documented inline and plan_id tied to prepare_compression's return value. The description only echoes the plan_id provenance already stated in the schema, so the baseline 3 applies.

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?

States a specific verb and resource ('用 prepare_compression 的结果替换原图' — replace the original image with the prepare_compression result), which is unambiguous and clearly distinct from prepare_compression (plans) and cancel_compression (aborts). The downstream artifact of the sibling tool is named directly, so the agent can place this in the workflow without opening any schema.

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

Usage Guidelines5/5

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

Gives an explicit gating precondition rather than a vague hint: call only after the user has seen the preview table and explicitly consented. This is effectively both a when-to-use and a when-not-to-use rule, and it ties the tool to the prepare_compression workflow, leaving no doubt about sequencing among the siblings.

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

cancel_compression取消压缩计划A

丢弃 prepare_compression 的结果并清理临时文件,原图不受影响。

NameRequiredDescriptionDefault
plan_idYes

TDQS

A4/5.0
Behavior4/5

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

With no annotations provided, the description carries the full burden and does disclose real side effects: temporary files are removed and the original image is explicitly left untouched, which answers the main safety question for a cancel tool. It omits failure behavior (e.g. invalid or already-consumed plan_id) and any permission requirements.

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?

One sentence, front-loaded with the primary action, with the clarifying guarantee (original unaffected) placed last. Every clause earns its place.

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

Completeness4/5

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

For a single-parameter, no-output-schema cleanup tool the description covers purpose, side effects, and safety. It is only short of explaining where plan_id comes from and what happens on an invalid or expired plan.

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?

There is one parameter at 0% schema description coverage, so plan_id is undocumented in the schema. The description implies provenance (it comes from prepare_compression) but never states that plan_id is that identifier, nor its format, so it only partially compensates for the coverage gap.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description names a specific action pair — discarding the prepare_compression result and cleaning temporary files — so the agent immediately understands this is the abort path of a three-step workflow. It differentiates itself from prepare_compression by naming it, but never names apply_compression, the sibling it actually competes with when a prepared plan is outstanding.

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

Usage Guidelines4/5

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

By stating that it discards the output of prepare_compression, the description anchors usage to a clear precondition: you have a prepared plan you no longer want. No explicit when-not or alternative (apply_compression) is offered, so the agent must infer the fork from the sibling list.

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

prepare_compression预览图片压缩A
Read-only

视觉无损压缩图片(JPEG/PNG/WebP/AVIF/GIF/SVG),结果存放在临时目录,不修改原图。返回 plan_id 和预览表。必须把预览表完整展示给用户,并在用户明确同意后才能调用 apply_compression。

NameRequiredDescriptionDefault
pathsYes图片文件或目录路径,建议使用绝对路径
effortNofast:跳过质量判定;balanced:默认;max:更高压缩率、更慢balanced
min_scoreNoSSIMULACRA2 及格线,85 为视觉无损
recursiveNo是否递归子目录

TDQS

A4.4/5.0
Behavior4/5

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

readOnlyHint=true is already declared, but the description adds real behavior the annotation cannot: output lands in a temp directory, the original files are untouched, and the call yields a plan_id plus a preview table. It does not cover failure modes or how long the plan_id remains valid, so not a full 5.

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?

Three tight sentences: capability and safety first, return values next, mandatory workflow constraint last. No repetition of the title or schema, and nothing padding.

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

Completeness4/5

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

For a two-phase prepare/apply workflow with no output schema, the description supplies the return contract (plan_id + preview table) and the human-approval gate, which is what an agent most needs. Minor gaps remain around plan expiry or preview-table scale limits.

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% and the schema already documents paths, effort, min_score, and recursive in detail (including the SSIMULACRA2 threshold and enum meanings). The description adds no parameter-level information, so the baseline 3 applies.

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?

States a specific verb+resource ('视觉无损压缩图片') plus supported formats and output location (临时目录, 不修改原图). It also names the sibling it hands off to (apply_compression), so an agent can distinguish it from apply_compression and cancel_compression without opening a schema.

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

Usage Guidelines5/5

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

Explicit sequencing rules: the preview table must be shown to the user in full, and apply_compression may only be called after the user's explicit consent. That is a when-to-use and when-not-to-use condition paired with the named alternative.

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.

  1. 3 tool updatesv0.1.0
    • First observedapply_compression
    • First observedcancel_compression
    • First observedprepare_compression

TDQS

A4.4/5.0

Scored across 3 tools

Disambiguation5/5

Each tool has a clearly distinct role in the workflow: prepare generates a compression plan and preview, apply commits the changes, and cancel discards the plan. There is no overlap in purpose, and the descriptions explicitly state when each should be used.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern in snake_case: prepare_compression, apply_compression, cancel_compression. The verbs are distinct and the noun is consistent, making the pattern predictable.

Tool Count5/5

With only 3 tools, the set is minimal but perfectly scoped to the compression workflow. Each tool corresponds to a necessary step (prepare, apply, cancel), and no extraneous tools are present.

Completeness5/5

The surface covers the full lifecycle: creating a compression plan with preview, committing the result, and aborting the operation. There are no obvious missing operations for the stated purpose of safe, preview-based image compression.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers