Mcp Image

io.github.shinpr由 GitHub 账号 shinpr 发布v0.19.0更新于 Nov 5, 2026

AI image generation and editing with prompt optimization and quality presets

已验证STDIO仅桌面媒体与设计AI 与机器学习

概览

AI 生成的概览

本地 MCP 服务器,通过 Gemini、OpenAI 或 BytePlus Seedream 按文字提示生成和编辑图片,并把结果保存到磁盘。

可以做什么
  • 根据文字提示生成图片,可指定画幅比例、尺寸、质量档位和提供商
  • 通过绝对路径传入输入图片,对现有图片进行编辑或合成
  • 生成前把简短请求改写为更详细的提示词,也可关闭该步骤
  • 把结果保存到指定输出目录,并以文件资源形式返回给助手
  • 可为已有图片生成工具的助手安装配套的提示词写作技能
适用场景
适合在 Codex、Cursor、Claude Code 等 MCP 客户端中让助手生成或修改图片,例如产品图、插画、海报、界面稿,并把文件保存到本地目录。
运行要求
通过 npx 在本地运行,需要 Node.js 22 或更高版本。需在客户端配置的服务器环境中提供所选提供商的 API 密钥:GEMINI_API_KEY(默认)、OPENAI_API_KEY,或 Seedream 的 ARK_API_KEY。IMAGE_OUTPUT_DIR 决定图片保存位置,建议使用绝对路径。OpenAI 可能需要组织验证。
安装前请注意
需要第三方付费 API 密钥;较高质量档位耗时更长、费用更高。密钥以环境变量形式传入,请勿提交到版本控制。提示词和参考图片会发送给所选提供商,Gemini 还可选用 Google 搜索接地。生成的文件会写入配置的输出目录。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Mcp Image,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

MCP Image Generator 🍌

Generate and edit images from Codex, Cursor, Claude Code, or any MCP client. mcp-image adds visual direction to your request before sending it to Gemini, OpenAI, or BytePlus Seedream.

[npm version] [npm downloads] [License: MIT]

Tell it what image to create or what to change in an existing image, and what it is for. The result is saved to disk and returned to your assistant.

What It Does

Before generating an image, mcp-image rewrites short requests into more specific prompts. It keeps what you asked for and fills in what the image needs for its use, such as lighting and camera angle for a photo or layout for a poster. Text you want in the image stays as you wrote it, in your language. The more detail you provide, the less it changes.

You ask:

"A photo of a roast chicken dinner for a recipe site. It should look like it was actually cooked, and it should be partway through being carved so you can tell how juicy it is."

mcp-image sends to the image model:

"... a freshly roasted whole chicken resting on a rustic, seasoned wooden carving board. The chicken features deeply bronzed, blistered, and crispy skin ... It is partway carved, with one breast cleanly sliced open to reveal tender, steaming-hot white meat glistening with natural juices pooling slightly onto the board ... shallow depth of field with a softly blurred background."

[Roast chicken, generated with prompt enhancement]

Generated with Gemini using the default fast quality preset.

What carried through:

  • for a recipe site: one clear subject, with everything else kept subordinate
  • actually cooked: blistered, uneven browning, rising steam, and drippings on the knife
  • partway through being carved: one breast sliced open, with the cut piece still resting against the bird
  • how juicy it is: juices pooling on the board and shallow depth of field around the cut
Compare the same request with prompt enhancement turned off [Baseline result with prompt enhancement turned off]

Baseline from the same request, with prompt enhancement disabled.

Set SKIP_PROMPT_ENHANCEMENT=true to send the original prompt to the image model unchanged.

Quick Start

You need Node.js 22 or later, an MCP-compatible client, and an API key for one image provider.

1. Get an API key

All three providers generate and edit images. Gemini is the default and requires the least configuration.

ProviderImage sizeOutput formatSetup
Gemini (default)1K, 2K, 4KAutomaticGet a key, then set GEMINI_API_KEY
OpenAI1K, 2K, 4KPNG or JPEGGet a key, then set IMAGE_PROVIDER=openai and OPENAI_API_KEY
BytePlus Seedream1K, 2KPNG or JPEGGet an AP region key, then set IMAGE_PROVIDER=seedream and ARK_API_KEY

Google Search grounding is available with Gemini only. OpenAI may require organization verification before it can generate images.

The examples below use Gemini. Replace the provider settings if you prefer OpenAI or Seedream.

2. Configure your MCP client

Codex

Add this to ~/.codex/config.toml:

toml
[mcp_servers.mcp-image]command = "npx"args = ["-y", "mcp-image"]
[mcp_servers.mcp-image.env]GEMINI_API_KEY = "your_gemini_api_key_here"IMAGE_OUTPUT_DIR = "/absolute/path/to/images"
Cursor

Add this to ~/.cursor/mcp.json for all projects, or .cursor/mcp.json in a project:

json
{  "mcpServers": {    "mcp-image": {      "command": "npx",      "args": ["-y", "mcp-image"],      "env": {        "GEMINI_API_KEY": "your_gemini_api_key_here",        "IMAGE_OUTPUT_DIR": "/absolute/path/to/images"      }    }  }}
Claude Code

Run this in your project directory:

bash
claude mcp add mcp-image --env GEMINI_API_KEY=your-api-key --env IMAGE_OUTPUT_DIR=/absolute/path/to/images -- npx -y mcp-image

Add --scope user after mcp-image to make it available in every project.

Never commit API keys to version control. Use an absolute IMAGE_OUTPUT_DIR in MCP configuration because the server's working directory depends on the client. If omitted, images are written to ./output relative to that working directory.

3. Generate an image

Restart your MCP client after changing its configuration, then ask your AI assistant:

text
Generate a product photo of a ceramic coffee mug on a wooden desk.

The generated file is saved in the configured output directory and returned to the assistant as an MCP resource.

Run mcp-image from a local checkout
bash
pnpm installpnpm run build

Configure the MCP client to run the local build instead of npx -y mcp-image:

bash
node /absolute/path/to/mcp-image/dist/index.js

More Examples

Edit an existing image

Give the assistant an absolute path to the source image:

text
Edit /path/to/image.jpg so the person is facing right.

Control the result

  • Generate a high-quality product photo of a smartphone with clear text on the screen.
  • Generate a cinematic desert landscape in a 21:9 aspect ratio.
  • Keep the knight's appearance consistent with the previous image.

See the tool reference for the options your assistant can pass explicitly.

Configuration

Changing the provider changes both prompt enhancement and image generation. The way you ask for an image stays the same.

Quality

IMAGE_QUALITY accepts fast (default), balanced, or quality. Set it in the MCP server environment:

bash
IMAGE_QUALITY=balanced

Use fast to try ideas quickly, balanced for everyday use, and quality for complex scenes or images where small details matter. Higher settings can take longer and cost more; results vary by provider.

All three providers support these presets for generation and editing. You can override the default with the quality option on each request.

Environment variables

VariableDefaultDescription
IMAGE_PROVIDERgeminiDefault provider: gemini, openai, or seedream
GEMINI_API_KEY-API key for Gemini
OPENAI_API_KEY-API key for OpenAI
ARK_API_KEY-ModelArk AP API key for Seedream
IMAGE_OUTPUT_DIR./outputDirectory where generated images are saved; use an absolute path in MCP configuration
IMAGE_QUALITYfastDefault quality preset: fast, balanced, or quality
SKIP_PROMPT_ENHANCEMENTfalseSet to true to send prompts through unchanged

You can configure keys for more than one provider and switch per request. A request-level provider option takes precedence over IMAGE_PROVIDER.

Tool Reference

Your MCP client calls this tool for you. Open the reference when you need to check an option or provider limitation.

generate_image parameters
ParameterTypeRequiredDescription
promptstringYesImage description or editing instruction
qualitystringNofast, balanced, or quality; overrides IMAGE_QUALITY
providerstringNogemini, openai, or seedream; overrides IMAGE_PROVIDER
inputImagePathsstring[]NoAbsolute paths to input images for editing
fileNamestringNoOutput filename; .png, .jpg, or .jpeg selects the format for OpenAI and Seedream
aspectRatiostringNo1:1 (default), 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9, 1:4, 1:8, 4:1, or 8:1
imageSizestringNo1K, 2K, or 4K; availability depends on the provider
blendImagesbooleanNoAdd blending guidance when combining visual elements
maintainCharacterConsistencybooleanNoKeep a character's appearance consistent across images
useWorldKnowledgebooleanNoAdd context for historical figures, landmarks, and factual scenes
useGoogleSearchbooleanNoGemini only. Use Google Search grounding for current information
purposestringNoIntended use, such as cookbook cover or social media post
categorystringNoKind of image: photo, illustration, asset, ui-screen, graphic-design, diagram, or pattern-texture. Your assistant sets it when the kind is clear

Troubleshooting

API key not found

Check that the key for the selected provider is present in the MCP server's environment:

  • Gemini: GEMINI_API_KEY
  • OpenAI: OPENAI_API_KEY
  • Seedream: ARK_API_KEY

Restart the MCP client after changing its configuration.

Input image file not found

Use absolute paths and make sure the MCP server can read the files. Input images can be PNG, JPEG, or WebP and must be no larger than 10 MiB each. Seedream editing accepts PNG and JPEG only.

Provider rejects a request

Check the requested size in the provider table. useGoogleSearch works with Gemini only, and Seedream does not support 4K. For OpenAI permission errors, check your organization settings. For quota or rate-limit errors, check the selected provider account.

Image Generation Prompt Skill

This repository also includes an Agent Skill for assistants that already have access to an image generation tool. It teaches the prompt-writing approach used by mcp-image and works independently of this server.

Install it with:

bash
npx mcp-image skills install --path <skills-directory>

For example, use ~/.codex/skills, ~/.cursor/skills, or ~/.claude/skills as the destination.

License

MIT License. See LICENSE for details.


Need help? Open an issue or check Troubleshooting.

来源:README.md,提交 6269dc8

工具

1

generate_image

Generate a new image from a text prompt or edit and combine reference images using inputImagePaths. Saves the result and returns a file resource. Prompt enhancement expands these arguments into the final image prompt without seeing the conversation, filling in the details they leave open, so pass the user's intent as they gave it; anything you add is expanded too. When a guess at the image's purpose or style would likely miss what the user needs, ask them first.

输入参数prompt必填purposequalitycategoryfileNameproviderimageSizeaspectRatioblendImagesinputImagePathsuseGoogleSearchuseWorldKnowledge另有 1 个

版本历史

9
  1. v0.19.0最新Nov 5, 2026
  2. v0.18.4Nov 4, 2026
  3. v0.18.3Nov 3, 2026
  4. v0.18.2Oct 22, 2026
  5. v0.18.1Oct 22, 2026
  6. v0.18.0Oct 8, 2026
  7. v0.17.0Oct 8, 2026
  8. v0.15.0Oct 5, 2026
  9. v0.14.0Sep 16, 2026

评分

已满足适用检查项的 90%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分
  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分