mcp-image-optimizer

mcp-image-optimizer

A Model Context Protocol server for image optimization with advanced transformations powered by Sharp, enabling resize, convert, batch process, crop, watermark, and favicon generation from URLs or local files.

Category
访问服务器

README

MCP Image Optimizer

A Model Context Protocol server for image optimization. Process images from URLs or local files with advanced transformations powered by Sharp.

Features

  • 🖼️ Process images from URLs or local files
  • 🔄 Resize, rotate, flip, blur, sharpen, and more
  • 📦 Batch process multiple images
  • 🎨 Convert between JPEG, PNG, WebP, AVIF, TIFF
  • ✂️ Auto-crop borders and whitespace
  • 🎯 Smart crop with attention detection
  • 🌫️ Generate low-quality placeholders (LQIP)
  • 💧 Add watermarks (image or text) with full control
  • 🌟 Generate favicons in all required sizes and formats

Installation

<details open> <summary>Install in Claude Code</summary>

Run this command to add the MCP server:

claude mcp add image-optimizer -- npx -y mcp-image-optimizer

See Claude Code MCP docs for more info.

</details>

<details> <summary>Install in Claude Desktop</summary>

Add to your Claude Desktop config file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json
{
  "mcpServers": {
    "image-optimizer": {
      "command": "npx",
      "args": ["mcp-image-optimizer"]
    }
  }
}

</details>

<details> <summary>Install in OpenAI Codex</summary>

Add the following configuration to your OpenAI Codex MCP server settings:

[mcp_servers.image-optimizer]
args = ["-y", "mcp-image-optimizer"]
command = "npx"

See OpenAI Codex for more information.

</details>

<details> <summary>Install in VSCode</summary>

Add to your VS Code settings for MCP extensions like Cline or Continue:

{
  "image-optimizer": {
    "command": "npx",
    "args": ["mcp-image-optimizer"]
  }
}

</details>

<details> <summary>Install in Cursor</summary>

Navigate to Settings → Cursor Settings → MCP → Add new global MCP server

Add to ~/.cursor/mcp.json:

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

</details>

<details> <summary>Alternative: Global Install</summary>

Install globally for faster startup:

npm install -g mcp-image-optimizer

Then use this simpler config in any client:

{
  "command": "mcp-image-optimizer"
}

</details>

Usage Examples

Ask your AI assistant:

  • "Optimize ~/Desktop/photo.jpg to 800px width"
  • "Convert https://images.pexels.com/photos/32206277/pexels-photo-32206277.jpeg to WebP"
  • "Batch optimize all images in ~/Downloads/"
  • "Create a 200x200 thumbnail with smart crop"
  • "Generate a placeholder for lazy loading"
  • "Add my company logo as watermark to product images"
  • "Add 'Copyright 2025' text watermark"
  • "Generate all favicon sizes from my logo"

Available Tools

<details> <summary><code>optimize_image</code></summary>

Resize, convert, and transform images.

Example:

"Optimize image.jpg to 800px width with 85% quality"

Parameters:

  • input - Image path or URL
  • output - Output file path
  • width - Target width in pixels
  • height - Target height in pixels
  • quality - Quality 1-100 for lossy formats
  • format - Output format (jpeg, png, webp, avif, tiff)
  • fit - Resize fit mode (cover, contain, fill, inside, outside)
  • Plus rotate, flip, grayscale, blur, sharpen, normalize

</details>

<details> <summary><code>batch_optimize</code></summary>

Process multiple images at once.

Example:

"Optimize all images in ~/Pictures/ to 1200px width"

Parameters:

  • inputs - Array of image paths or URLs
  • outputDir - Output directory
  • width, height, quality, format - Same as single image
  • prefix - Add to filename start
  • suffix - Add to filename end

</details>

<details> <summary><code>get_image_info</code></summary>

Extract image metadata.

Example:

"Get info about image.jpg"

Returns:

  • Dimensions, format, color space
  • File size, DPI
  • EXIF data presence

</details>

<details> <summary><code>auto_crop</code></summary>

Remove borders and whitespace automatically.

Example:

"Auto-crop screenshot.png to remove white borders"

Parameters:

  • input - Image path or URL
  • output - Output file path
  • threshold - Color similarity threshold 0-100
  • backgroundColor - Background to detect

</details>

<details> <summary><code>smart_crop</code></summary>

Intelligent cropping to specific dimensions.

Example:

"Smart crop portrait.jpg to 500x500 square"

Parameters:

  • input - Image path or URL
  • output - Output file path
  • width, height - Target dimensions
  • strategy - "attention" or "entropy"

</details>

<details> <summary><code>create_placeholder</code></summary>

Generate low-quality image placeholders for lazy loading.

Example:

"Create a blurred placeholder for hero-image.jpg"

Parameters:

  • input - Image path or URL
  • width - Placeholder width (default: 20)
  • height - Placeholder height (auto if not set)
  • quality - JPEG quality 1-100 (default: 40)
  • blur - Blur amount 0.3-1000 (default: 5)
  • format - "base64", "datauri", or "file"

</details>

<details> <summary><code>add_watermark</code></summary>

Add image or text watermarks with positioning and styling.

Example:

"Add logo.png as watermark to photo.jpg in bottom-right corner"
"Add 'Copyright 2025' text watermark with 50% opacity"
"Add 'CONFIDENTIAL' diagonally across the document"

Parameters:

  • input - Image path or URL
  • output - Output file path
  • watermark - Path/URL to watermark image, base64 data, or text
  • position - Corner, center, diagonal, or tile pattern
  • opacity - Transparency 0-1
  • scale - Size relative to base image
  • margin - Distance from edges
  • blend - Blend mode for effects
  • Text options: text, fontSize, fontColor, fontFamily

</details>

<details> <summary><code>generate_favicon</code></summary>

Generate all favicon sizes and formats for modern web apps.

Example:

"Generate favicons from logo.png and save to ./public"
"Create all icon sizes for my PWA"

Parameters:

  • input - Source image (recommend 512x512 or larger)
  • outputDir - Directory to save all favicon files
  • sizes - Custom sizes array (default: all standard sizes)
  • platforms - Target platforms: web, apple, android, microsoft, all
  • generateManifest - Create manifest.json snippet for PWAs

Generated files:

  • PNG favicons in all sizes (16x16 to 512x512)
  • apple-touch-icon.png (180x180)
  • android-chrome-192x192.png, android-chrome-512x512.png
  • mstile-150x150.png (Microsoft tile)
  • favicon-html.txt (ready-to-use HTML tags)
  • manifest-icons.json (PWA configuration)

</details>

Path Support

  • URLs: https://example.com/image.jpg
  • Absolute paths: /Users/name/Desktop/image.jpg
  • Home directory: ~/Desktop/image.jpg
  • ⚠️ Relative paths: Works with cwd config setting

To use relative paths, add a working directory:

{
  "command": "npx",
  "args": ["mcp-image-optimizer"],
  "cwd": "/Users/yourname/Desktop"
}

Requirements

  • Node.js 22+ (npx handles this automatically)
  • Compatible MCP client

Troubleshooting

"Command not found"

  • Make sure Node.js is installed: node --version
  • Try the global install method

"File not found"

  • Use absolute paths: /Users/name/Desktop/image.jpg
  • Check file permissions

"MCP tools not available"

  • Restart your MCP client after configuration
  • Check config file is valid JSON

License

MIT

Links

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选