Skip to main content
Glama

Image Converter MCP Server

npm version License: MIT Node.js Version

基于MCP(Model Context Protocol)协议的多格式图像转换服务器,支持JPG/PNG/WebP/GIF/BMP/TIFF/SVG/ICO/AVIF等格式互转。提供高性能的图像处理能力,支持批量转换、尺寸调整、质量控制等功能。

✨ 特性

  • 🔄 多格式支持: 支持15+种图片格式互转

  • 📁 批量处理: 一次性转换多个图片文件

  • 🎯 智能输入: 支持文件路径和直接数据输入两种方式

  • 📏 尺寸控制: 支持自定义宽高和保持宽高比

  • 🎨 质量调节: 支持压缩质量控制(1-100)

  • 高性能: 基于Sharp和Jimp双引擎处理

  • 🛡️ 类型安全: 完整的TypeScript支持

  • 🔍 详细信息: 提供图片元数据查询功能

Related MCP server: Omni File Converter MCP

📦 安装

使用 npm

npm install -g image-converter-mcp-server

使用 yarn

yarn global add image-converter-mcp-server

从源码安装

git clone https://github.com/pickstar-2025/image-converter-mcp.git
cd image-converter-mcp
npm install
npm run build

🚀 使用方法

作为MCP服务器启动

# 直接启动
image-converter-mcp-server

# 或使用npx
npx image-converter-mcp-server

在MCP客户端中使用

将以下配置添加到您的MCP客户端配置文件中:

{
  "mcpServers": {
    "image-converter": {
      "command": "npx",
      "args": ["image-converter-mcp-server"]
    }
  }
}

📖 API参考

convert_image

转换单个图片文件

interface ConvertImageParams {
  input_path?: string;           // 源图片文件路径
  input_data?: string | Buffer;  // 图片数据(Buffer或base64字符串)
  input_filename?: string;       // 原始文件名,用于确定格式
  output_format: string;         // 目标格式(必需)
  quality?: number;              // 压缩质量(1-100)
  width?: number;                // 目标宽度
  height?: number;               // 目标高度
  maintain_aspect_ratio?: boolean; // 保持宽高比,默认true
  output_path?: string;          // 输出文件路径
}

使用示例:

{
  "tool": "convert_image",
  "arguments": {
    "input_path": "./photos/image.jpg",
    "output_format": "webp",
    "quality": 80,
    "width": 800
  }
}

batch_convert_images

批量转换多个图片文件

interface BatchConvertParams {
  input_paths?: string[];        // 源图片文件路径数组
  input_files?: Array<{          // 上传的文件数据数组
    data: string | Buffer;
    filename: string;
  }>;
  output_format: string;         // 目标格式(必需)
  quality?: number;              // 压缩质量
  width?: number;                // 目标宽度
  height?: number;               // 目标高度
  maintain_aspect_ratio?: boolean; // 保持宽高比
  output_directory?: string;     // 输出目录
}

get_image_info

获取图片文件信息

interface GetImageInfoParams {
  image_path?: string;           // 图片文件路径
  image_data?: string | Buffer;  // 图片数据
}

list_supported_formats

列出所有支持的图片格式

{
  "tool": "list_supported_formats",
  "arguments": {}
}

🎯 支持的格式

输入格式

  • JPEG/JPG - 标准JPEG格式

  • PNG - 便携式网络图形

  • GIF - 图形交换格式

  • BMP - 位图格式

  • TIFF/TIF - 标记图像文件格式

  • WebP - 现代Web图像格式

  • SVG - 可缩放矢量图形

  • ICO - 图标格式

  • AVIF - AV1图像文件格式

  • HEIC/HEIF - 高效图像格式(需要系统支持)

  • PSD - Photoshop文档(有限支持)

输出格式

  • JPEG/JPG - 有损压缩,适合照片

  • PNG - 无损压缩,支持透明度

  • WebP - 现代格式,优秀的压缩比

  • GIF - 支持动画

  • BMP - 无压缩位图

  • TIFF - 高质量存档格式

  • ICO - Windows图标格式

  • AVIF - 下一代图像格式

  • SVG - 矢量图形格式

⚙️ 配置

环境变量

# 设置临时文件目录
TEMP_DIR=/path/to/temp

# 设置最大文件大小(字节)
MAX_FILE_SIZE=10485760

# 设置并发处理数量
MAX_CONCURRENT=4

配置文件

创建 config.json 文件:

{
  "tempDir": "./temp",
  "maxFileSize": 10485760,
  "maxConcurrent": 4,
  "defaultQuality": 80,
  "supportedFormats": {
    "input": ["jpg", "png", "gif", "bmp", "tiff", "webp", "svg", "ico", "avif"],
    "output": ["jpg", "png", "gif", "bmp", "tiff", "webp", "svg", "ico", "avif"]
  }
}

📝 使用示例

基础转换

# 将JPEG转换为WebP
{
  "tool": "convert_image",
  "arguments": {
    "input_path": "photo.jpg",
    "output_format": "webp",
    "quality": 85
  }
}

调整尺寸

# 转换并调整尺寸
{
  "tool": "convert_image",
  "arguments": {
    "input_path": "large_image.png",
    "output_format": "jpg",
    "width": 800,
    "height": 600,
    "maintain_aspect_ratio": true
  }
}

批量转换

# 批量转换多个文件
{
  "tool": "batch_convert_images",
  "arguments": {
    "input_paths": ["img1.png", "img2.jpg", "img3.gif"],
    "output_format": "webp",
    "quality": 80,
    "output_directory": "./converted"
  }
}

处理上传数据

# 处理base64编码的图片数据
{
  "tool": "convert_image",
  "arguments": {
    "input_data": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD...",
    "input_filename": "uploaded.jpg",
    "output_format": "png"
  }
}

🏗️ 开发

本地开发

# 克隆仓库
git clone https://github.com/pickstar-2025/image-converter-mcp.git
cd image-converter-mcp

# 安装依赖
npm install

# 开发模式
npm run dev

# 构建项目
npm run build

# 运行测试
npm test

项目结构

image-converter-mcp/
├── src/
│   ├── index.ts              # 主入口文件
│   ├── converter.ts          # 图像转换核心逻辑
│   ├── file-handler.ts       # 文件处理工具
│   ├── temp-file-manager.ts  # 临时文件管理
│   ├── stream-processor.ts   # 流处理器
│   └── usage-examples.ts     # 使用示例
├── dist/                     # 编译输出目录
├── image-test/              # 测试图片目录
├── package.json
├── tsconfig.json
└── README.md

🚀 部署

Git仓库部署

  1. 初始化Git仓库

git init
git add .
git commit -m "Initial commit"
  1. 添加远程仓库

git remote add origin https://github.com/your-username/image-converter-mcp.git
git branch -M main
git push -u origin main
  1. 版本标签

git tag v1.0.0
git push origin v1.0.0

NPM包发布

  1. 准备发布

# 登录npm
npm login

# 检查包信息
npm pack --dry-run
  1. 发布到NPM

# 发布
npm publish

# 发布beta版本
npm publish --tag beta
  1. 版本管理

# 更新版本
npm version patch  # 1.0.0 -> 1.0.1
npm version minor  # 1.0.0 -> 1.1.0
npm version major  # 1.0.0 -> 2.0.0

# 发布新版本
npm publish

必需的配置文件

package.json

{
  "name": "image-converter-mcp-server",
  "version": "1.0.0",
  "description": "基于MCP协议的多格式图像转换服务器",
  "main": "dist/index.js",
  "type": "module",
  "bin": {
    "image-converter-mcp-server": "./dist/index.js"
  },
  "files": [
    "dist/**/*",
    "README.md",
    "package.json"
  ],
  "engines": {
    "node": ">=18.0.0"
  }
}

.gitignore

node_modules/
dist/
*.log
.env
.DS_Store
temp/
coverage/
.nyc_output/

.npmignore

src/
*.ts
!*.d.ts
tsconfig.json
.git/
.github/
tests/
coverage/
.nyc_output/

🤝 贡献指南

我们欢迎所有形式的贡献!请遵循以下步骤:

报告问题

  1. 检查现有的Issues

  2. 创建新的Issue,包含:

    • 问题描述

    • 复现步骤

    • 期望行为

    • 实际行为

    • 环境信息

提交代码

  1. Fork项目

git clone https://github.com/your-username/image-converter-mcp.git
cd image-converter-mcp
  1. 创建功能分支

git checkout -b feature/your-feature-name
  1. 提交更改

git add .
git commit -m "feat: add your feature description"
  1. 推送分支

git push origin feature/your-feature-name
  1. 创建Pull Request

代码规范

  • 使用TypeScript编写代码

  • 遵循ESLint配置

  • 添加适当的测试

  • 更新相关文档

  • 提交信息遵循Conventional Commits

提交信息格式

type(scope): description

[optional body]

[optional footer]

类型:

  • feat: 新功能

  • fix: 修复bug

  • docs: 文档更新

  • style: 代码格式调整

  • refactor: 代码重构

  • test: 测试相关

  • chore: 构建过程或辅助工具的变动

📄 许可证

本项目采用 MIT License 许可证。

MIT License

Copyright (c) 2024 CodeBuddy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

👨‍💻 作者信息

CodeBuddy

🙏 致谢

感谢以下开源项目:

📊 统计信息

GitHub stars GitHub forks GitHub issues GitHub pull requests


Available Tools

4 tools
batch_convert_imagesC

批量转换多个图片文件

ParametersJSON Schema
NameRequiredDescriptionDefault
input_pathsNo源图片文件路径数组(与input_files二选一)
input_filesNo上传的文件数据数组(与input_paths二选一)
output_formatYes目标格式
qualityNo压缩质量
widthNo目标宽度
heightNo目标高度
maintain_aspect_ratioNo保持宽高比
output_directoryNo输出目录

TDQS

C2.9/5.0
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It states 'convert' which implies mutation but doesn't disclose whether files are overwritten, if conversion is lossy, authentication requirements, rate limits, or error handling for partial failures in batch operations.

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?

The description is a single, efficient phrase that directly states the tool's purpose without redundancy. It's appropriately sized for a batch processing tool and front-loads the core functionality.

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

Completeness2/5

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

For a batch mutation tool with 8 parameters, no annotations, and no output schema, the description is insufficient. It lacks critical context about output location, file naming conventions, conversion behavior, error handling, and performance characteristics that would help an agent use it correctly.

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%, providing detailed parameter documentation. The description adds no parameter-specific information beyond the schema's comprehensive descriptions, so it meets the baseline for high schema coverage without compensating value.

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 '批量转换多个图片文件' clearly states the action (convert) and resource (multiple image files) in Chinese. It distinguishes from sibling 'convert_image' by specifying batch processing, but doesn't explicitly contrast with other siblings like 'get_image_info' or 'list_supported_formats'.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention when batch conversion is preferred over single-file 'convert_image', nor does it reference prerequisites like supported formats or file size limits.

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

convert_imageC

将图片转换为指定格式

ParametersJSON Schema
NameRequiredDescriptionDefault
input_pathNo源图片文件路径(与input_data二选一)
input_dataNo图片数据(Buffer或base64字符串,与input_path二选一)
input_filenameNo原始文件名,用于确定格式(使用input_data时建议提供)
output_formatYes目标格式(png/jpg/jpeg/gif/bmp/tiff/webp/svg/ico等)
qualityNo压缩质量(1-100,仅适用于有损格式)
widthNo目标宽度(像素)
heightNo目标高度(像素)
maintain_aspect_ratioNo保持宽高比
output_pathNo输出文件路径(可选,默认自动生成)

TDQS

C2.9/5.0
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure but offers minimal information. It states the conversion action but doesn't mention whether this is a read-only operation, what permissions might be needed, whether original files are modified, what happens with invalid inputs, or what the output looks like. For a tool with 9 parameters and no annotations, this is a significant gap in behavioral context.

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?

The description is extremely concise with just one sentence ('将图片转换为指定格式'), which efficiently states the core purpose without any wasted words. It's appropriately sized for a tool where parameter details are fully covered in the schema, making every word earn its place.

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

Completeness2/5

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

Given the tool's complexity (9 parameters, format conversion with quality/resizing options) and absence of both annotations and output schema, the description is insufficiently complete. It doesn't explain what the tool returns (converted image data? file path? success status?), doesn't mention error conditions, and provides no behavioral context for a potentially destructive operation. The 100% schema coverage helps but doesn't compensate for missing output and behavioral information.

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%, so the schema already documents all 9 parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema - it doesn't explain parameter interactions, default behaviors, or practical usage examples. With complete schema coverage, the baseline score of 3 is appropriate as the description doesn't compensate but doesn't need to.

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 clearly states the tool's purpose as converting images to specified formats ('将图片转换为指定格式'), which is a specific verb+resource combination. It distinguishes from siblings like batch_convert_images (batch processing), get_image_info (metadata retrieval), and list_supported_formats (format listing) by focusing on single image conversion. However, it doesn't explicitly mention the single-image scope versus batch processing.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. There's no mention of when to choose convert_image over batch_convert_images for multiple images, or when to use get_image_info for metadata instead. The only implied usage is for format conversion, but no explicit context or exclusion criteria are provided.

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

get_image_infoC

获取图片文件信息

ParametersJSON Schema
NameRequiredDescriptionDefault
image_pathNo图片文件路径(与image_data二选一)
image_dataNo图片数据(Buffer或base64字符串,与image_path二选一)

TDQS

C2.7/5.0
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It only states what the tool does ('获取图片文件信息') without mentioning any behavioral traits such as performance characteristics, error handling, or what happens with invalid inputs. This leaves significant gaps in understanding how the tool behaves in practice.

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?

The description is a single, efficient sentence in Chinese ('获取图片文件信息') that directly states the tool's purpose without any wasted words. It's appropriately sized and front-loaded, making it easy to understand at a glance.

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

Completeness2/5

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

Given the lack of annotations and output schema, the description is incomplete. It doesn't explain what information is returned (e.g., dimensions, format, metadata), how errors are handled, or any limitations. For a tool with two parameters and no structured output documentation, more context is needed to be fully useful.

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?

The schema description coverage is 100%, with clear descriptions for both parameters ('image_path' and 'image_data') and their mutual exclusivity. The description adds no additional meaning beyond what the schema provides, so it meets the baseline of 3 where the schema does the heavy lifting.

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

Purpose3/5

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

The description '获取图片文件信息' (Get image file information) states a clear verb ('获取' - get) and resource ('图片文件信息' - image file information), but it's somewhat vague about what specific information is retrieved (dimensions, format, metadata, etc.). It doesn't differentiate from siblings like 'list_supported_formats' which also provides information, though about different aspects.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention prerequisites, context, or comparisons to sibling tools like 'batch_convert_images' or 'convert_image'. Users must infer usage from the tool name alone.

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

list_supported_formatsB

列出支持的图片格式

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

B3.2/5.0
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. The description only states what the tool does ('列出支持的图片格式') without any behavioral traits such as whether it requires authentication, has rate limits, returns a static list or dynamic data, or how the output is structured. For a tool with zero annotation coverage, this is a significant gap in transparency.

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?

The description is a single, efficient sentence ('列出支持的图片格式') that directly states the tool's purpose with zero waste. It is appropriately sized and front-loaded, making it easy to understand at a glance without unnecessary elaboration.

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

Completeness3/5

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

Given the tool's low complexity (0 parameters, no annotations, no output schema), the description is minimally complete. It states the purpose clearly but lacks behavioral context (e.g., output format, authentication needs) and usage guidelines. For a simple list tool, this is adequate but leaves gaps that could hinder an AI agent's effective use, especially without annotations to compensate.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters, and the schema description coverage is 100% (as there are no parameters to describe). The description doesn't need to add parameter semantics beyond the schema, so it meets the baseline of 4 for tools with no parameters, as it doesn't introduce any confusion or redundancy regarding inputs.

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 '列出支持的图片格式' (List supported image formats) clearly states the tool's purpose with a specific verb ('列出' - list) and resource ('支持的图片格式' - supported image formats). It distinguishes from siblings like 'batch_convert_images' and 'convert_image' which perform conversions rather than listing formats. However, it doesn't explicitly differentiate from 'get_image_info' which might provide format information for specific images.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to use it (e.g., before conversion to check compatibility) or when not to use it (e.g., for getting format info about a specific image). There's no reference to sibling tools like 'get_image_info' for comparison, leaving usage context implied at best.

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. Dates show when Glama detected each change.

  1. 4 tool updates
    • First observedbatch_convert_images
    • First observedconvert_image
    • First observedget_image_info
    • First observedlist_supported_formats

TDQS

A3.5/5.0
Disambiguation5/5

Each tool has a clearly distinct purpose: batch_convert_images handles multiple files, convert_image handles single files, get_image_info retrieves metadata, and list_supported_formats provides format information. There is no overlap or ambiguity between these functions.

Naming Consistency5/5

All tools follow a consistent snake_case naming pattern with clear verb_noun combinations (batch_convert_images, convert_image, get_image_info, list_supported_formats). The naming is predictable and follows the same convention throughout.

Tool Count5/5

With 4 tools, this server is well-scoped for image conversion tasks. Each tool serves a specific, necessary function without redundancy, making the count appropriate for the domain.

Completeness5/5

The toolset provides complete coverage for basic image conversion workflows: listing formats, getting image info, converting single images, and batch converting images. There are no obvious gaps for the server's stated purpose.

Maintenance

ActivityInactive
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pickstar-2002/image-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server