article
README
🚀 TinyPNG的MCP服务器
TinyPNG的MCP服务器为图像压缩提供了便捷的服务,支持本地和远程图像的压缩,可与Claude Desktop集成使用。
🚀 快速开始
使用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": "your-tinypng-api-key"
}
}
}
}
通过Smithery进行安装
若要通过 Smithery 自动为Claude Desktop安装TinyPNG MCP服务器,可执行以下命令:
npx -y @smithery/cli install @aiyogg/tinypng-mcp-server --client claude
💻 使用示例
基础用法
1. 压缩本地图像
{
name: 'compress_local_image',
description: 'Compress a local image file',
inputSchema: {
type: 'object',
properties: {
imagePath: {
type: 'string',
description: 'The ABSOLUTE path to the image file to compress',
example: '/Users/user/Downloads/image.jpg',
},
outputPath: {
type: 'string',
description: 'The ABSOLUTE path to save the compressed image file',
example: '/Users/user/Downloads/image_compressed.jpg',
},
outputFormat: {
type: 'string',
description: 'The format to save the compressed image file',
enum: SUPPORTED_IMAGE_TYPES,
example: 'image/jpeg',
},
},
required: ['imagePath'],
},
}
2. 压缩远程图像
{
name: 'compress_remote_image',
description: 'Compress a remote image file by giving the URL of the image',
inputSchema: {
type: 'object',
properties: {
imageUrl: {
type: 'string',
description: 'The URL of the image file to compress',
example: 'https://example.com/image.jpg',
},
outputPath: {
type: 'string',
description: 'The ABSOLUTE path to save the compressed image file',
example: '/Users/user/Downloads/image_compressed.jpg',
},
outputFormat: {
type: 'string',
description: 'The format to save the compressed image file',
enum: SUPPORTED_IMAGE_TYPES,
example: 'image/jpeg',
},
},
required: ['imageUrl'],
},
}
Scan to join WeChat group