Skip to main content
Glama

🚀 快速入门

npx -y @cloudwerxlab/gpt-image-1-mcp

📋 先决条件

🔑 环境变量

💻 NPX 用法示例

# Set your OpenAI API key
export OPENAI_API_KEY=sk-your-openai-api-key

# Optional: Set custom output directory
export GPT_IMAGE_OUTPUT_DIR=/home/username/Pictures/ai-generated-images

# Run the server with NPX
npx -y @cloudwerxlab/gpt-image-1-mcp
# Set your OpenAI API key
$env:OPENAI_API_KEY = "sk-your-openai-api-key"

# Optional: Set custom output directory
$env:GPT_IMAGE_OUTPUT_DIR = "C:\Users\username\Pictures\ai-generated-images"

# Run the server with NPX
npx -y @cloudwerxlab/gpt-image-1-mcp
:: Set your OpenAI API key
set OPENAI_API_KEY=sk-your-openai-api-key

:: Optional: Set custom output directory
set GPT_IMAGE_OUTPUT_DIR=C:\Users\username\Pictures\ai-generated-images

:: Run the server with NPX
npx -y @cloudwerxlab/gpt-image-1-mcp

Related MCP server: OpenAI MCP

🔌 与 MCP 客户端集成

🛠️ 在 MCP 客户端中设置

{
  "mcpServers": {
    "gpt-image-1": {
      "command": "npx",
      "args": [
        "-y",
        "@cloudwerxlab/gpt-image-1-mcp"
      ],
      "env": {
        "OPENAI_API_KEY": "PASTE YOUR OPEN-AI KEY HERE",
        "GPT_IMAGE_OUTPUT_DIR": "OPTIONAL: PATH TO SAVE GENERATED IMAGES"
      }
    }
  }
}

不同操作系统的示例配置

{
  "mcpServers": {
    "gpt-image-1": {
      "command": "npx",
      "args": ["-y", "@cloudwerxlab/gpt-image-1-mcp"],
      "env": {
        "OPENAI_API_KEY": "sk-your-openai-api-key",
        "GPT_IMAGE_OUTPUT_DIR": "C:\\Users\\username\\Pictures\\ai-generated-images"
      }
    }
  }
}
{
  "mcpServers": {
    "gpt-image-1": {
      "command": "npx",
      "args": ["-y", "@cloudwerxlab/gpt-image-1-mcp"],
      "env": {
        "OPENAI_API_KEY": "sk-your-openai-api-key",
        "GPT_IMAGE_OUTPUT_DIR": "/home/username/Pictures/ai-generated-images"
      }
    }
  }
}

注意:对于 Windows 路径,请使用双反斜杠 ( \\ ) 来转义 JSON 中的反斜杠字符。对于 Linux/macOS,请使用正斜杠 ( / )。

✨ 特点

💡 增强功能

🔄 工作原理

📁 输出目录行为

安装和使用

NPM 包

此软件包可在 npm 上获取: @cloudwerxlab/gpt-image-1-mcp

您可以全局安装它:

npm install -g @cloudwerxlab/gpt-image-1-mcp

或者直接使用 npx 运行它,如快速入门部分所示。

工具: create_image

根据文本提示生成新图像。

参数

范围

类型

必需的

描述

prompt

细绳

是的

要生成的图像的文本描述(最多 32,000 个字符)

size

细绳

不

图像尺寸:“1024x1024”(默认)、“1536x1024”或“1024x1536”

quality

细绳

不

图像质量:“高”(默认)、“中”或“低”

n

整数

不

生成的图像数量(1-10,默认值:1)

background

细绳

不

背景样式:“透明”、“不透明”或“自动”(默认)

output_format

细绳

不

输出格式:“png”(默认)、“jpeg”或“webp”

output_compression

整数

不

压缩级别(0-100,默认值:0)

user

细绳

不

OpenAI 使用情况跟踪的用户标识符

moderation

细绳

不

审核级别:“低”或“自动”(默认)

例子

<use_mcp_tool>
<server_name>gpt-image-1</server_name>
<tool_name>create_image</tool_name>
<arguments>
{
  "prompt": "A futuristic city skyline at sunset, digital art",
  "size": "1024x1024",
  "quality": "high",
  "n": 1,
  "background": "auto"
}
</arguments>
</use_mcp_tool>

回复

该工具返回:

  • 包含所生成图像详细信息的格式化文本消息

  • 以 base64 编码的数据格式显示图像

  • 元数据包括令牌使用情况和文件路径

工具: create_image_edit

根据文本提示和可选掩码编辑现有图像。

参数

范围

类型

必需的

描述

image

字符串、对象或数组

是的

要编辑的图像(base64字符串或文件路径对象)

prompt

细绳

是的

所需编辑的文本描述(最多 32,000 个字符)

mask

字符串或对象

不

定义要编辑的区域的掩码(base64字符串或文件路径对象)

size

细绳

不

图像尺寸:“1024x1024”(默认)、“1536x1024”或“1024x1536”

quality

细绳

不

图像质量:“高”(默认)、“中”或“低”

n

整数

不

生成的图像数量(1-10,默认值:1)

background

细绳

不

背景样式:“透明”、“不透明”或“自动”(默认)

user

细绳

不

OpenAI 使用情况跟踪的用户标识符

Base64 编码图像示例

<use_mcp_tool>
<server_name>gpt-image-1</server_name>
<tool_name>create_image_edit</tool_name>
<arguments>
{
  "image": "BASE64_ENCODED_IMAGE_STRING",
  "prompt": "Add a small robot in the corner",
  "mask": "BASE64_ENCODED_MASK_STRING",
  "quality": "high"
}
</arguments>
</use_mcp_tool>

文件路径示例

<use_mcp_tool>
<server_name>gpt-image-1</server_name>
<tool_name>create_image_edit</tool_name>
<arguments>
{
  "image": {
    "filePath": "C:/path/to/your/image.png"
  },
  "prompt": "Add a small robot in the corner",
  "mask": {
    "filePath": "C:/path/to/your/mask.png"
  },
  "quality": "high"
}
</arguments>
</use_mcp_tool>

回复

该工具返回:

  • 包含已编辑图像详细信息的格式化文本消息

  • 编辑后的图像作为 base64 编码数据

  • 元数据包括令牌使用情况和文件路径

🔧 故障排除

🚨常见问题

🔍 错误处理和报告

MCP 服务器包含全面的错误处理功能,可在出现问题时提供详细信息。发生错误时:

  1. 错误格式:所有错误均返回:

    • 清晰的错误信息,描述出了什么问题

    • 具体的错误代码或类型

    • 如果有关于错误的附加上下文

  2. AI 助手行为:当此 MCP 服务器与 AI 助手一起使用时:

    • 人工智能将始终报告完整的错误消息以帮助排除故障

    • 人工智能将用通俗易懂的语言解释错误的可能原因

    • 人工智能将建议解决问题的具体步骤

📄 许可证

🙏 致谢

Available Tools

2 tools
create_imageD
ParametersJSON Schema
NameRequiredDescriptionDefault
promptYes
backgroundNo
nNo
output_compressionNo
output_formatNo
qualityNo
sizeNo
userNo
moderationNo

TDQS

D1/5.0
Behavior1/5

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

Tool has no description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness1/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Tool has no description.

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

Completeness1/5

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

Tool has no description.

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

Parameters1/5

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

Tool has no description.

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

Purpose1/5

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

Tool has no description.

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

Usage Guidelines1/5

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

Tool has no description.

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

create_image_editD
ParametersJSON Schema
NameRequiredDescriptionDefault
imageYes
promptYes
backgroundNo
maskNo
nNo
qualityNo
sizeNo
userNo

TDQS

D1/5.0
Behavior1/5

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

Tool has no description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness1/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Tool has no description.

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

Completeness1/5

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

Tool has no description.

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

Parameters1/5

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

Tool has no description.

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

Purpose1/5

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

Tool has no description.

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

Usage Guidelines1/5

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

Tool has no description.

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.

  1. 2 tool updates
    • First observedcreate_image
    • First observedcreate_image_edit

TDQS

D1.5/5.0

Scored across 2 tools

Disambiguation2/5

The two tools have overlapping purposes—both involve creating images—and without descriptions, it's unclear how they differ. 'create_image_edit' suggests editing an existing image, but this could easily be confused with the base 'create_image' tool, leading to potential misselection.

Naming Consistency5/5

Both tools follow a consistent verb_noun pattern with 'create_image' as the base, and 'create_image_edit' extends this logically. The naming is predictable and clear, with no deviations in style or convention.

Tool Count2/5

With only 2 tools, the server feels thin for an image-related domain, which typically requires operations like listing, retrieving, updating, or deleting images. This limited set may not support common workflows, making it under-scoped.

Completeness1/5

The tool surface is severely incomplete for an image server; there are no tools for reading, updating, deleting, or managing images beyond creation and editing. This will cause significant agent failures in handling image lifecycles or varied tasks.

Maintenance

ActivityInactive
ResponsivenessUnresponsive

Related MCP Connectors

Related MCP Servers