image-mcp

image-mcp

Provides 80+ image processing tools including AI generation, background removal, upscaling, local manipulation, and diagram rendering, all with built-in cost tracking and health monitoring.

Category
访问服务器

README

image-mcp

MCP server for advanced image processing operations with AI capabilities, local processing, and comprehensive tool discovery.

Features

  • 80+ Image Processing Tools: Comprehensive toolkit for all image manipulation needs
  • TypeScript MCP Server: Built with @modelcontextprotocol/sdk
  • Tool Discovery System: Built-in introspection and documentation tools
  • Tool Registry Pattern: Dynamic tool loading and management
  • Local Processing: CPU-based operations with Sharp.js (no API keys needed)
  • AI-Powered Tools: Image generation, background removal, upscaling, inpainting
  • Binary Data Handling: Automatic base64 encoding for small images (<1MB)
  • URL Reference Pattern: Large images (>1MB) written to disk with path references
  • Batch Operations: Process multiple images efficiently
  • Graceful Error Handling: Provider unavailability and timeout handling
  • Cost Management: Built-in budget controls and spending alerts
  • Health Monitoring: Automatic provider health checks
  • File I/O Patterns: Support for file paths, URLs, and base64 input/output
  • Diagram Generation: Graphviz (DOT) and Mermaid diagram rendering
  • Canvas Annotations: Draw text, shapes, and labels on images

Quick Start

Installation

# Clone the repository
git clone <repository-url>
cd image-mcp

# Install dependencies
npm install

# Build the project
npm run build

Configuration

  1. Copy the example environment file:
cp .env.example .env
  1. Add your API keys (optional - local processing works without any keys):
# At minimum, add ONE AI generation provider:
SEEDREAM_API_KEY=your_key_here        # Recommended for quality
FAL_KEY=your_key_here                 # Recommended for creativity
OPENAI_API_KEY=sk-your_key_here       # Recommended for ease of use

See the Configuration Guide for detailed setup instructions.

MCP Server Setup

Add to your Claude Desktop or MCP client configuration:

{
  "mcpServers": {
    "image-mcp": {
      "command": "node",
      "args": ["/absolute/path/to/image-mcp/dist/index.js"],
      "env": {
        "SEEDREAM_API_KEY": "your_key_here",
        "FAL_KEY": "your_key_here"
      }
    }
  }
}

Verify Installation

Once connected, use the discovery tools to verify everything is working:

Use the "list_tools" tool to see all available image processing tools
Use the "list_providers" tool to check which AI providers are configured
Use the "get_capabilities" tool to see what operations are available

Tool Categories

Discovery Tools (Built-in Introspection)

  • list_tools - List all available tools with descriptions and categories
  • list_providers - List configured AI providers and their status
  • get_tool_help - Get detailed help for a specific tool
  • get_capabilities - See what operations are available with current configuration

Local Processing Tools (No API Keys Required)

  • Image Manipulation: resize, crop, rotate, flip
  • Format Conversion: JPEG, PNG, WebP, AVIF, TIFF, GIF
  • Compression: Optimize file sizes for web and storage
  • Color Adjustments: brightness, contrast, saturation, tint
  • Filters: blur, sharpen, grayscale
  • Watermarking: Add text or image watermarks
  • Compositing: Overlay and blend images
  • Metadata: Extract EXIF and image information

AI-Powered Tools (Requires API Keys)

  • Image Generation: Create images from text prompts (Seedream, FLUX, DALL-E, Ideogram)
  • Background Removal: Professional background removal (Photoroom, Remove.bg)
  • Upscaling: AI super-resolution (Replicate)
  • Inpainting: Remove objects and fill intelligently (Replicate, IOPaint)

Batch Processing Tools

  • Process multiple images in parallel
  • Apply transformations to entire folders
  • Progress tracking and error handling

Diagram Generation Tools

  • Graphviz: Generate graphs from DOT language
  • Mermaid: Flowcharts, sequence diagrams, class diagrams, Gantt charts
  • Specialized Diagrams: Flowcharts, dependency graphs, ER diagrams, architecture diagrams

Canvas & Annotation Tools

  • Draw text with custom fonts and styles
  • Add shapes (rectangles, circles, arrows)
  • Label images for documentation
  • Create visual annotations

Fetch & Screenshot Tools

  • Fetch images from URLs
  • Capture website screenshots
  • Handle image downloads

Example Workflows

Web Optimization Pipeline

1. Fetch image from URL
2. Resize to target dimensions (1920x1080)
3. Compress with quality 85
4. Convert to WebP format
5. Generate thumbnail (400x300)

Social Media Export Workflow

1. Generate image with AI (landscape concept)
2. Remove background (if needed)
3. Resize for Instagram (1080x1080)
4. Resize for Twitter (1200x675)
5. Add watermark to both
6. Compress for web delivery

Screenshot Annotation Workflow

1. Fetch screenshot from URL
2. Add text labels to highlight features
3. Draw arrows pointing to key elements
4. Add rectangular highlights
5. Export as PNG for documentation

AI-Assisted Design Workflow

1. Generate base image with AI
2. Remove background
3. Upscale to high resolution
4. Adjust brightness and contrast
5. Add watermark
6. Export in multiple formats

See docs/WORKFLOWS.md for detailed workflow examples.

Documentation

Development

npm run dev   # Watch mode with hot reload
npm run lint  # Run ESLint
npm run test  # Run Jest tests
npm run format # Format code with Prettier

Adding New Tools

See docs/DEVELOPMENT.md for guide on adding new tools to the registry.

Architecture

src/
├── index.ts                    # Server entry point
├── server.ts                   # MCP server implementation
├── types.ts                    # Core type definitions
├── config/
│   ├── provider-config.ts      # API key and provider configuration
│   ├── health-monitor.ts       # Provider health monitoring
│   └── cost-tracker.ts         # Cost tracking and budget controls
├── registry/
│   └── tool-registry.ts        # Tool registry for dynamic loading
├── utils/
│   ├── binary.ts               # Binary data handling utilities
│   ├── timeout.ts              # Timeout handling utilities
│   ├── diagram-utils.ts        # Diagram generation utilities
│   └── screenshot.ts           # Screenshot capture utilities
└── tools/
    ├── discovery-tools.ts      # Tool discovery and introspection
    ├── sharp-tools.ts          # Local image processing (Sharp.js)
    ├── ai-generation-tools.ts  # AI image generation
    ├── bg-removal-tools.ts     # Background removal
    ├── upscaling-tools.ts      # AI upscaling
    ├── inpainting-tools.ts     # AI inpainting
    ├── batch-tools.ts          # Batch processing
    ├── canvas-tools.ts         # Canvas annotations
    ├── diagram-tools.ts        # Diagram generation
    ├── fetch-tools.ts          # URL fetching and screenshots
    └── example-tools.ts        # Example implementations

Cost Management

The server includes built-in cost tracking and budget controls:

# Set spending limits
PROVIDER_DAILY_COST_LIMIT=10.00
PROVIDER_MONTHLY_COST_LIMIT=100.00
PROVIDER_PER_OPERATION_LIMIT=1.00

# Enable cost alerts
PROVIDER_COST_ALERTS=true
PROVIDER_COST_ALERT_THRESHOLDS=50,75,90

See docs/COST_MANAGEMENT.md for details.

Health Monitoring

Automatic health checks keep track of provider availability:

PROVIDER_HEALTH_CHECK_ENABLED=true
PROVIDER_HEALTH_CHECK_INTERVAL=300  # 5 minutes
PROVIDER_HEALTH_CHECK_TIMEOUT=10    # 10 seconds

Use the list_providers tool with checkHealth: true to see current status.

Graceful Degradation

The server automatically falls back to alternative providers if the primary fails:

PROVIDER_GRACEFUL_DEGRADATION=true
PROVIDER_FALLBACKS=seedream:flux,dalle3;openai:replicate

Security

  • API keys loaded from environment variables only
  • Keys never logged or exposed in error messages
  • Validation of API key format on startup
  • Secure handling of temporary files
  • No credential storage in code or configuration files

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

License

MIT

Support

  • GitHub Issues: Report bugs or request features
  • Documentation: Check docs/ folder for detailed guides
  • Use get_tool_help tool for specific tool documentation

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选