io.github.shinpr/mcp-image

平台与服务

by shinpr

基于 Nano Banana 的 AI 图像生成 MCP server,支持智能增强 prompt,帮助产出更优图片效果。

想把图像生成接入 MCP 工作流时,mcp-image 能直接提供基于 Nano Banana 的出图能力,还会智能增强 prompt,让成片效果更稳更好。

什么是 io.github.shinpr/mcp-image

基于 Nano Banana 的 AI 图像生成 MCP server,支持智能增强 prompt,帮助产出更优图片效果。

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 details such as composition, lighting, and camera angle. 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 beautifully roasted whole chicken, golden-brown and glistening, resting on a rustic wooden cutting board. One leg is partially carved, revealing tender, succulent white meat and rich, glistening juices pooling around the carving knife ... shallow depth of field focused on the carved chicken."

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: uneven browning and juices across the board
  • partway through being carved: the cut face and slices beside it
  • how juicy it is: close framing and shallow depth of field around the cut
<details> <summary>Compare the same request with prompt enhancement turned off</summary> <img src="assets/roast-chicken-plain.jpg" alt="Baseline result with prompt enhancement turned off" width="480">

Baseline from the same request, with prompt enhancement disabled.

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

</details>

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.

<details> <summary>Run mcp-image from a local checkout</summary>
bash
pnpm install
pnpm 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
</details>

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.

<details> <summary><code>generate_image</code> parameters</summary>
ParameterTypeRequiredDescription
promptstringYesImage description or editing instruction
qualitystringNofast, balanced, or quality; overrides IMAGE_QUALITY
providerstringNogemini, openai, or seedream; overrides IMAGE_PROVIDER
inputImagePathstringNoAbsolute path to an input image 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
</details>

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 an absolute path and make sure the MCP server can read the file. Input images can be PNG, JPEG, or WebP and must be no larger than 10 MB. 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.

常见问题

io.github.shinpr/mcp-image 是什么?

基于 Nano Banana 的 AI 图像生成 MCP server,支持智能增强 prompt,帮助产出更优图片效果。

相关 Skills

MCP构建

by anthropics

Universal
热门

聚焦高质量 MCP Server 开发,覆盖协议研究、工具设计、错误处理与传输选型,适合用 FastMCP 或 MCP SDK 对接外部 API、封装服务能力。

想让 LLM 稳定调用外部 API,就用 MCP构建:从 Python 到 Node 都有成熟指引,帮你更快做出高质量 MCP 服务器。

平台与服务
未扫描175.1k

Slack动图

by anthropics

Universal
热门

面向Slack的动图制作Skill,内置emoji/消息GIF的尺寸、帧率和色彩约束、校验与优化流程,适合把创意或上传图片快速做成可直接发送的Slack动画。

帮你快速做出适配 Slack 的动图,内置约束规则和校验工具,少踩上传与播放坑,做表情包和演示都更省心。

平台与服务
未扫描175.1k

接口测试套件

by alirezarezvani

Universal
热门

扫描 Next.js、Express、FastAPI、Django REST 的 API 路由,自动生成覆盖鉴权、参数校验、错误码、分页、上传与限流场景的 Vitest 或 Pytest 测试套件。

帮你把API与集成测试自动化跑顺,减少回归漏测;能力全面,尤其适合复杂接口场景的QA团队。

平台与服务
未扫描25.7k

相关 MCP Server

Slack 消息

编辑精选

by Anthropic

热门

Slack 是让 AI 助手直接读写你的 Slack 频道和消息的 MCP 服务器。

这个服务器解决了团队协作中需要 AI 实时获取 Slack 信息的痛点,特别适合开发团队让 Claude 帮忙汇总频道讨论或发送通知。不过,它目前只是参考实现,文档有限,不建议在生产环境直接使用——更适合开发者学习 MCP 如何集成第三方服务。

平台与服务
89.7k

by netdata

热门

io.github.netdata/mcp-server 是让 AI 助手实时监控服务器指标和日志的 MCP 服务器。

这个工具解决了运维人员需要手动检查系统状态的痛点,最适合 DevOps 团队让 Claude 自动分析性能数据。不过,它依赖 NetData 的现有部署,如果你没用过这个监控平台,得先花时间配置。

平台与服务
80.0k

by d4vinci

热门

Scrapling MCP Server 是专为现代网页设计的智能爬虫工具,支持绕过 Cloudflare 等反爬机制。

这个工具解决了爬取动态网页和反爬网站时的头疼问题,特别适合需要批量采集电商价格或新闻数据的开发者。不过,它依赖外部浏览器引擎,资源消耗较大,不适合轻量级任务。

平台与服务
72.9k

评论