gpt-image-mcp

gpt-image-mcp

MCP server for AI-powered image generation using OpenAI's gpt-image-1 and gpt-image-2 models with advanced text rendering and native transparency support.

Category
访问服务器

README

gpt-image MCP

npm version License: MIT OpenAI Documentation

MCP server for AI-powered image generation using OpenAI's gpt-image-1 and gpt-image-2 models with advanced text rendering and native transparency support.

Features

  • Advanced text rendering with gpt-image-1 - Crisp, legible typography and logos in generated images
  • Native transparency support - Built-in transparent background without post-processing
  • Multi-format output (PNG, JPEG, WebP) - Flexible format options with optimized compression
  • Flexible dimensions and aspect ratios - Square (1024×1024), landscape (1536×1024), and portrait (1024×1536)
  • Batch image editing capabilities - Process multiple images with parallel processing
  • Token-optimized MCP responses - Efficient response formats for MCP protocol limits

Installation

Recommended: Using npx

{
  "mcpServers": {
    "gpt-image-mcp": {
      "command": "npx",
      "args": ["@napolab/gpt-image-mcp"],
      "env": {
        "OPENAI_API_KEY": "sk-your-api-key"
      }
    }
  }
}

Alternative: Local Installation

npm install -g @napolab/gpt-image-mcp

Claude Desktop Configuration

Configure in ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):

{
  "mcpServers": {
    "gpt-image-mcp": {
      "command": "npx",
      "args": ["@napolab/gpt-image-mcp"],
      "env": {
        "OPENAI_API_KEY": "sk-your-api-key"
      }
    }
  }
}

Configuration

Environment Variables

Variable Required Default Description
OPENAI_API_KEY Yes - Your OpenAI API key
DEFAULT_OUTPUT_DIR No ./generated_images Default output directory
DEFAULT_IMAGE_SIZE No 1024x1024 Default image dimensions
DEFAULT_IMAGE_QUALITY No standard Default quality (standard/hd)
DEFAULT_OUTPUT_FORMAT No png Default format (png/jpeg/webp)

Available Tools

generate-image

Generate images using gpt-image-1 with advanced text rendering and superior instruction following.

Parameters:

Parameter Type Required Default Description
prompt string Yes - Image description (English only)
aspect_ratio string No square "square", "landscape", or "portrait"
quality string No standard "standard" or "hd"
output_directory string No ./generated_images Directory to save the image
filename string No - Custom filename
save_to_file boolean No true Whether to save locally
include_base64 boolean No false Include base64 in response

Example:

await client.callTool("generate-image", {
  prompt: "A serene Japanese garden with cherry blossoms",
  aspect_ratio: "landscape",
  quality: "hd",
});

edit-image

Edit existing images with AI-powered modifications including inpainting, outpainting, style transfer, and background changes.

Parameters:

Parameter Type Required Default Description
source_image object Yes - Image input (URL, base64, or local file)
edit_prompt string Yes - Description of desired changes (English only)
edit_type string Yes - Type of edit to perform
strength number No 0.8 Edit strength (0.0 to 1.0)
preserve_composition boolean No true Maintain original composition
output_format string No png Output format

Edit Types:

  • inpaint - Fill in or modify specific areas
  • outpaint - Extend image beyond boundaries
  • background_change - Replace or modify background
  • style_transfer - Apply artistic styles
  • object_removal - Remove unwanted objects
  • variation - Create variations of original

Example:

await client.callTool("edit-image", {
  source_image: {
    type: "local",
    value: "/path/to/image.jpg",
  },
  edit_prompt: "Add a sunset sky background",
  edit_type: "background_change",
});

batch-edit

Apply the same edit to multiple images efficiently with parallel processing.

Parameters:

Parameter Type Required Default Description
images array Yes - Array of image inputs
edit_prompt string Yes - Edit description (English only)
edit_type string Yes - Type of edit to apply
batch_settings object No - Batch processing configuration

Example:

await client.callTool("batch-edit", {
  images: [
    { type: "local", value: "/path/to/image1.jpg" },
    { type: "local", value: "/path/to/image2.jpg" },
  ],
  edit_prompt: "Apply vintage sepia filter",
  edit_type: "style_transfer",
});

Usage Examples

Basic Image Generation

// Generate a simple image
const result = await client.callTool("generate-image", {
  prompt: "A modern minimalist logo design",
  aspect_ratio: "square",
  quality: "hd",
});

console.log("Generated image:", result.data.file_path);

Advanced Options

// Generate with all parameters
const result = await client.callTool("generate-image", {
  prompt: "Professional product photography of a smartphone",
  aspect_ratio: "portrait",
  quality: "hd",
  output_directory: "./product_images",
  filename: "smartphone_hero",
  output_format: "png",
  include_base64: true,
});

Image Editing

// Generate base image
const baseImage = await client.callTool("generate-image", {
  prompt: "A mountain landscape",
  aspect_ratio: "landscape",
});

// Edit the generated image
const editedImage = await client.callTool("edit-image", {
  source_image: {
    type: "local",
    value: baseImage.data.file_path,
  },
  edit_prompt: "Add dramatic storm clouds",
  edit_type: "background_change",
  strength: 0.7,
});

Batch Processing

// Process multiple images
const result = await client.callTool("batch-edit", {
  images: [
    { type: "local", value: "image1.jpg" },
    { type: "local", value: "image2.jpg" },
    { type: "local", value: "image3.jpg" },
  ],
  edit_prompt: "Apply Instagram-style filter",
  edit_type: "style_transfer",
  batch_settings: {
    max_concurrent: 3,
    error_handling: "continue_on_error",
  },
});

Development

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Submit a pull request

Testing

# Run tests
npm test

# Run tests in watch mode
npm run test:watch

# Run linting
npm run lint

# Type checking
npm run typecheck

Building

# Build for production
npm run build

# Development mode with hot reload
npm run dev

License

MIT License - see the LICENSE file for details.

Support

推荐服务器

Baidu Map

Baidu Map

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

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

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

官方
精选
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

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

官方
精选
本地
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

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

官方
精选
本地
TypeScript
VeyraX

VeyraX

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

官方
精选
本地
Kagi MCP Server

Kagi MCP Server

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

官方
精选
Python
graphlit-mcp-server

graphlit-mcp-server

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

官方
精选
TypeScript
mcp-server-qdrant

mcp-server-qdrant

这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。

官方
精选
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

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

官方
精选