Image Gen

com.nuverlabs由 nuverlabs.com 发布v0.2.1更新于 Oct 24, 2026

Generate and edit images from your coding agent with Gemini and OpenAI, using your own API keys.

已验证STDIO仅桌面开发者工具媒体与设计

概览

AI 生成的概览

一个本地 MCP 服务器,让编程助手使用你自己的 Gemini 或 OpenAI API 密钥生成和编辑图片,并把文件保存到项目中。

可以做什么
根据文本提示生成图片,可选择服务商、模型、宽高比、数量、质量、背景和尺寸,保存到指定路径或目录并返回绝对路径。用文本指令编辑或合成已有图片,最多使用 16 张源图,且不会覆盖原图。报告已配置的服务商、默认模型、输出目录回退顺序以及当前生效的目录限制。
适用场景
适合让助手在项目内直接产出博客封面、标志、图标、占位插画或图片变体,再读取保存的文件继续调整。也适合已持有 Gemini 或 OpenAI API 密钥、希望用同一接口调用两家的用户。
运行要求
以 npm 包形式通过 npx 在本地运行,需要 Node.js。服务器环境中必须至少设置 GEMINI_API_KEY 或 OPENAI_API_KEY 之一,两者各自可选。可选配置包括默认服务商与模型、输出目录、允许目录、超时和日志文件。需要访问服务商 API 的网络。
安装前请注意
每次调用都是计费 API 请求,没有内置速率限制或费用上限,重试循环可能快速产生费用,建议在服务商侧设置支出上限。提示词和编辑用的源图会发送给所选服务商。除非设置 IMAGE_GEN_MCP_ALLOWED_DIRS,否则文件读写默认不受限制,且服务器以你的完整用户权限运行。本地 JSONL 记录默认以明文保存截断后的提示词。写入客户端配置文件的密钥以明文存放。

安装

在 SourceWeft 中

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

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

其他 MCP 客户端

参照 仓库 中的启动说明。

README

image-gen-mcp

[npm] [CI] [license] [Node]

Generate and edit images from your coding agent, with your own API keys. Ask for a blog cover, a logo tweak, or a placeholder illustration, and the file lands directly in your project where the agent can read it and iterate.

Google Gemini image models (the Nano Banana family) and OpenAI GPT image models behind one interface. Configure one provider or both.

[A terminal window emitting a gradient ribbon that resolves into three generated image thumbnails]

This banner and the repository's social preview card were both generated by this server, with gemini-3.1-flash-image at 16:9 2K. Prompts are in assets/README.md.

Install

bash
claude mcp add image-gen --scope user \  --env GEMINI_API_KEY=your-gemini-key \  --env OPENAI_API_KEY=your-openai-key \  -- npx -y @nuver-labs/image-gen-mcp

Start a new Claude Code session to pick it up, then check claude mcp list.

Three things that trip people up:

  • At least one option must sit between the last --env and the server name. Above, --scope does that job. Put the name straight after an --env pair and the CLI reads it as another KEY=value.
  • -- before the command is mandatory. Without it the server's own arguments get parsed as Claude Code's.
  • Drop the --env line for any provider you do not use. You need at least one.

Get keys from Google AI Studio and the OpenAI platform.

Other clients

Same package everywhere. For .mcp.json (project scope, commit it) and Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json):

json
{  "mcpServers": {    "image-gen": {      "command": "npx",      "args": ["-y", "@nuver-labs/image-gen-mcp"],      "env": {        "GEMINI_API_KEY": "your-gemini-key",        "OPENAI_API_KEY": "your-openai-key"      }    }  }}

Claude Code also accepts a per-server "timeout": 600000, which Claude Desktop does not. Cursor uses the same shape in .cursor/mcp.json. On Windows, GUI hosts cannot always find npx, so use "command": "cmd" with "args": ["/c", "npx", "-y", "@nuver-labs/image-gen-mcp"].

Use it

Just ask, in plain language:

  • "Generate a 16:9 hero image of a lighthouse at dusk and save it to assets/hero.png"
  • "Take public/logo.png and give it a transparent background"
  • "Create 3 variations of a flat paper airplane icon, square, into design/drafts/"

The agent calls generate_image or edit_image with an absolute output_path inside your project, the file lands on disk, and the agent can then read the saved path to look at the result and refine it. If a call fails, ask it to run list_capabilities to see what is actually configured.

Tools

ToolWhat it does
generate_imageText prompt to one or more image files. Returns the absolute saved paths.
edit_imageEdit or combine existing images with a text instruction. Never overwrites the sources.
list_capabilitiesWhich providers are configured, default models, and the output directory rules.

generate_image

ArgumentTypeNotes
promptstring, requiredSubject, style, composition, colors, any text to render
output_pathstringAbsolute file path (.png/.jpg/.webp) or a directory. Given a directory, the filename is slugified from the prompt
providergemini | openaiOverrides the default provider
modelstringGemini: gemini-3.1-flash-image (default), gemini-3.1-flash-lite-image, gemini-3-pro-image, gemini-2.5-flash-image. OpenAI: gpt-image-2 (default), gpt-image-1.5, gpt-image-1, gpt-image-1-mini
aspect_ratio1:1 2:3 3:2 3:4 4:3 9:16 16:9 21:9Exact on Gemini and gpt-image-2. Older OpenAI models approximate: landscape 1536x1024, portrait 1024x1536
n1-4Gemini generates sequentially, so n>1 is slower there
qualitylow medium high autoOpenAI only. low for cheap drafts
backgroundtransparent opaque autoOpenAI only. Ideal for logos and icons. Needs gpt-image-1.5 or older, so transparent on gpt-image-2 auto-switches to gpt-image-1.5 and says so in the result
image_size1K 2K 4KGemini 3.x only
return_imagebooleanAlso return the first image inline so the model can see it without a read. Costs context tokens

edit_image

Everything above, plus:

ArgumentTypeNotes
source_pathsstring[], required1-16 absolute paths (.png/.jpg/.jpeg/.webp). The first is the edit target, the rest are references. Gemini works best with 1-3
input_fidelitylow | highOpenAI only. high preserves faces, logos, and fine detail. Ignored on gpt-image-2, which is always high fidelity

When output_path is omitted, the result is saved next to the first source image.

list_capabilities

No arguments. Reports configured providers as booleans (never key values), the default provider and models, known model options, the output directory fallback chain, and any directory restriction in force.

Configuration

VariableDefaultPurpose
GEMINI_API_KEY(unset)Enables the Gemini provider
OPENAI_API_KEY(unset)Enables the OpenAI provider
IMAGE_GEN_MCP_DEFAULT_PROVIDERkey-basedgemini or openai. When unset: gemini if its key is set, else openai
IMAGE_GEN_MCP_GEMINI_MODELgemini-3.1-flash-imageDefault Gemini model
IMAGE_GEN_MCP_OPENAI_MODELgpt-image-2Default OpenAI model
IMAGE_GEN_MCP_OUTPUT_DIR(unset)Fallback output directory when a call passes no output_path
IMAGE_GEN_MCP_ALLOWED_DIRS(unset)Comma separated directories that all reads and writes are confined to. See Security
IMAGE_GEN_MCP_TIMEOUT_MS180000Per-request timeout to the provider API
IMAGE_GEN_MCP_LOG_FILE~/.image-gen-mcp/images.jsonlJSONL ledger path. Absolute path to relocate, none to disable the file

With no output_path, files go to the first of: IMAGE_GEN_MCP_OUTPUT_DIR, CLAUDE_PROJECT_DIR (set by Claude Code, points at the current project), the server working directory.

Security

This server runs locally with your full user privileges and is not sandboxed by the MCP client. Worth understanding before you grant it blanket tool approval.

What it can do. Writes image files to disk. Reads the image files you point edit_image at. Sends your prompt, and any edit_image source image, to the provider you selected. Makes billable API calls. That is the whole surface: three tools, no shell execution, no arbitrary URL fetching, no telemetry.

File access. The model chooses output_path and source_paths, and by default they are unrestricted, because that is what makes the tool useful: your agent saves into whichever project you are working in. Note that Claude Code's working-directory boundary does not extend to MCP servers, and Anthropic does not security-audit third-party MCP servers.

To draw a hard boundary, set IMAGE_GEN_MCP_ALLOWED_DIRS:

bash
IMAGE_GEN_MCP_ALLOWED_DIRS=/Users/you/projects,/Users/you/Desktop

Every output path and every edit_image source must then resolve inside one of those roots. Paths are compared after realpath resolution, so a symlink pointing out of a root is refused, and containment uses path segments rather than a string prefix, so a sibling directory like /Users/you/projects-private does not slip through. If none of the configured entries exist, the server refuses all file access rather than silently running unrestricted.

API keys. Keys are read only from the environment, passed to the provider SDK constructors, and used nowhere else. They are never logged, never written to the ledger, and never returned by list_capabilities, which reports booleans.

The risk is where you put them, not what this server does with them. Keys inlined into ~/.claude.json or claude_desktop_config.json sit in plaintext, readable by any process running as you, and an agent asked to read its own config can print them into a transcript. Prefer exporting from a shell profile or a secret manager, chmod 600 the config files, and use a dedicated key with a spend limit rather than a shared production key.

Spend. There is no built-in rate limit or cap. An agent in a retry loop can generate a lot of images quickly. Set OpenAI hard spend limits and Google Cloud budget alerts.

Local log. The ledger at ~/.image-gen-mcp/images.jsonl contains a truncated copy of each prompt in plaintext and grows without bound. Disable it with IMAGE_GEN_MCP_LOG_FILE=none, and do not commit it.

Prompt injection. Tool results re-enter the model's context. Prefer per-call approval over blanket-allowing this server, and glance at the output path and any edit_image source path when approving. Pin a version and review the diff before upgrading.

Found a vulnerability? See SECURITY.md. Please do not open a public issue.

Logging

Every successful call records one structured JSON entry, two ways:

  • stderr, always: one [image-gen-mcp] image {...} line, visible in /mcp output and Claude Code logs.
  • JSONL ledger, on by default: the same JSON appended to ~/.image-gen-mcp/images.jsonl, one line per call. Ledger write failures never break a generation, they warn once on stderr.

Each entry captures the provider, model, requested size, elapsed seconds, a truncated prompt with its full character count, token usage when the provider reports it, and per-image details: saved path, byte size, human-readable size, mime type, and actual pixel dimensions.

bash
tail -n 20 ~/.image-gen-mcp/images.jsonljq 'select(.usage) | .usage.totalTokens' ~/.image-gen-mcp/images.jsonl

Costs

Every call hits a paid API, typically cents per image, varying by provider, model, quality, and size. Cheap options for drafts: OpenAI quality: low (roughly $0.006 for a low-quality 1024x1024 on gpt-image-2) or gpt-image-1-mini, and Gemini gemini-3.1-flash-lite-image. Gemini's gemini-2.5-flash-image may have a free tier on unbilled keys, so IMAGE_GEN_MCP_GEMINI_MODEL=gemini-2.5-flash-image makes it the default.

Timeouts

Generation takes roughly 10 to 120 seconds depending on model and size. Claude Code's defaults are generous and this server sends progress notifications during long calls, so no tuning is normally needed. If you set a tight global MCP_TOOL_TIMEOUT, add a per-server "timeout": 600000 in .mcp.json.

Troubleshooting

  • Server logs go to stderr with an [image-gen-mcp] prefix. Claude Code surfaces them in /mcp output and its logs.
  • Registered but no tools: start a new session, then check claude mcp list and claude mcp get image-gen.
  • Provider 'x' is not configured: that key is missing from the MCP server environment. Re-register with the --env flag or edit your config.
  • Output is outside the allowed directories: IMAGE_GEN_MCP_ALLOWED_DIRS is set. Run list_capabilities to see the roots.
  • Response too large: return_image inlines a full image and can exceed the MCP output token limit (MAX_MCP_OUTPUT_TOKENS, default 25k). Leave it off and let the agent read the saved file.
  • Gemini refusal: the error includes the finish reason and any provider text. Rephrase the prompt.

Build from source

Requires Node 22+ and pnpm.

bash
git clone https://github.com/nuver-labs/image-gen-mcp.gitcd image-gen-mcppnpm installpnpm build

Then point your client at node /abs/path/to/image-gen-mcp/dist/index.js instead of npx -y @nuver-labs/image-gen-mcp.

bash
pnpm test      # unit tests, no API keys neededpnpm inspect   # list the tools over real MCP stdio
# Live tests. These cost real API credits.GEMINI_API_KEY=... node dist/smoke.js --provider geminiOPENAI_API_KEY=... node dist/smoke.js --provider openainode dist/smoke.js --provider gemini --edit ./smoke-output/smoke-gen-gemini.png

Contributing

Bug reports, provider quirk fixes, and documentation improvements are welcome. See CONTRIBUTING.md. For anything larger, open an issue first.

Planned: OpenAI mask and inpainting support, migration off the legacy Gemini generateContent image path to the Interactions API, and more providers.

License

MIT


Built by Nuver Labs.

来源:README.md,提交 fa70937

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.2.1最新Sep 16, 2026

评分

已满足适用检查项的 50%

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

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

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

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分