TinyPNG 的 MCP 服务器可助力用户便捷地对图片进行压缩处理,支持本地和远程图片的压缩操作,同时提供了多种安装和使用方式。
bun 或 node 运行服务器pnpm i
pnpm build
mcp.json 文件{
"mcpServers": {
"tinypng": {
"command": "bun", // 或 "node"
"args": ["/path/to/tinypng-mcp-server/src/index.ts"], // 或 "dist/index.js"
"env": {
"TINYPNG_API_KEY": "你的 TinyPNG API 密钥"
}
}
}
}
要通过 Smithery 自动安装 TinyPNG MCP Server for Claude Desktop,可执行以下命令:
npx -y @smithery/cli install @aiyogg/tinypng-mcp-server --client claude
{
name: 'compress_local_image',
description: '压缩一个本地图片文件',
inputSchema: {
type: 'object',
properties: {
imagePath: {
type: 'string',
description: '要压缩的图片文件的绝对路径',
example: '/Users/user/Downloads/image.jpg',
},
outputPath: {
type: 'string',
description: '保存压缩后图片文件的绝对路径',
example: '/Users/user/Downloads/image_compressed.jpg',
},
outputFormat: {
type: 'string',
description: '保存压缩后图片文件的格式',
enum: SUPPORTED_IMAGE_TYPES,
example: 'image/jpeg',
},
},
required: ['imagePath'],
},
}
{
name: 'compress_remote_image',
description: '通过提供图片的 URL 来压缩远程图片文件',
inputSchema: {
type: 'object',
properties: {
imageUrl: {
type: 'string',
description: '要压缩的图片文件的 URL',
example: 'https://example.com/image.jpg',
},
outputPath: {
type: 'string',
description: '保存压缩后图片文件的绝对路径',
example: '/Users/user/Downloads/image_compressed.jpg',
},
outputFormat: {
type: 'string',
description: '保存压缩后图片文件的格式',
enum: SUPPORTED_IMAGE_TYPES,
example: 'image/jpeg',
},
},
required: ['imageUrl'],
},
}