runware-image-mcp

runware-image-mcp

Enables Claude Code agents to generate images via the Runware API with full parameter control, exact USD cost reporting, local image saving, and a live gallery.

Category
访问服务器

README

runware-image-mcp — Runware image generation for Claude agents

A self-hosted MCP server that lets Claude Code agents generate images directly via the Runware API — full parameter control, exact per-image USD cost reporting, every image saved locally, and a live localhost gallery to browse everything your agents create.

Typical cost: $0.0013/image (FLUX.1 schnell) to $0.0038/image (FLUX.1 dev, the default) at 1024×1024 — versus ~$0.50/image on hosted image-MCP subscriptions.

Setup (3 commands)

  1. Get an API key at my.runware.ai (pay-per-use, new accounts get free credits).

  2. Build:

    npm install && npm run build
    
  3. Register with Claude Code (either way):

    claude mcp add runware -e RUNWARE_API_KEY=<your-key> -- node "$PWD/dist/index.js"
    

    …or copy .mcp.json.example to .mcp.json in your project and fill in the absolute path + key. Restart your Claude Code session afterwards.

The gallery is then live at http://127.0.0.1:7788 while any session with the server is open.

Runtime dependencies are kept minimal: the MCP SDK, zod, and sharp (for local resize_image; ships prebuilt binaries, so npm install needs no build tools on macOS/Linux/Windows).

Tools

Tool What it does
generate_image Text→image (and img2img / inpainting) with any Runware model. Params: prompt, negative_prompt, model (AIR id), width/height or aspect_ratio (e.g. "16:9"), steps, cfg_scale, scheduler, seed, number_results, lora, seed_image + strength, mask_image, output_format, output_quality, vae, clip_skip, check_nsfw, return_image, extra_params (raw Runware passthrough). Returns local file path, seed, and exact USD cost.
search_models Search Runware's 30k+ model catalog; returns AIR ids plus recommended defaults and trigger words.
upscale_image AI upscale 2–4× via Runware (local path, URL, or previous imageUUID). Costs money; enhances detail.
resize_image Resize a local image to exact pixel dimensions — local, instant, free (no API call). Exact icon sizes, @1x/@2x retina pairs, precise widths, PNG→WEBP conversion; preserves transparency; contain/cover/fill/inside/outside fit modes. For AI quality enlargement use upscale_image.
remove_background Background removal (result is PNG with alpha).
list_generated_images Query the local generation history (prompt/model/project/date filters).

Dimensions are auto-adjusted to Runware's grid (multiples of 64 within 128–2048) and the response tells you when that happened. Seeds are always returned so agents can reproduce or vary a result.

Gallery

  • Live grid of all generations (newest first) with prompt, model, seed, cost, and a running total spend; updates automatically as agents generate.
  • Lightbox with copy-prompt / copy-seed buttons; filter by prompt text, model, or the project the image was generated from; failures view.
  • Binds 127.0.0.1 only (not configurable), Host-header allowlisted, CSP'd.
  • Multiple concurrent Claude sessions share one gallery: the first instance owns the port, all instances write to the same image dir.

Configuration (env vars)

Var Default Purpose
RUNWARE_API_KEY Required for generation; without it, tools return setup instructions
IMAGE_GEN_DIR ~/.image-gen-mcp Images + manifest location (shared across sessions)
GALLERY_PORT 7788 Gallery port
GALLERY on off disables the gallery
DEFAULT_MODEL runware:101@1 (FLUX.1 dev) Model when the agent doesn't pick one
MAX_RESULTS_PER_CALL 4 Cap on number_results
IMAGE_GEN_ALLOWED_DIRS Extra colon-separated dirs allowed as local seed_image sources
RUNWARE_TIMEOUT_MS 120000 API request timeout
RUNWARE_CDN_HOST_SUFFIX .runware.ai Download host pin

Privacy & security notes

  • ~/.image-gen-mcp/manifest.jsonl and the images are plaintext on disk (dir 0700, files 0600); prompts may contain project context.
  • The only outbound connections are api.runware.ai and the Runware CDN. No telemetry.
  • Local seed_image files must be real images (extension + magic bytes) inside allowlisted directories — a prompt-injected agent can't feed ~/.ssh/id_rsa to the API.
  • The API key lives only in your MCP registration (.mcp.json is gitignored here); it is never logged, stored in the manifest, or shown in the gallery.

Development

npm run build       # tsc + copy gallery assets (run before tests)
npm run typecheck
npm run test        # offline suite — no network, no key, no spend
npm run test:live   # opt-in real-API smoke (~$0.003, needs a key)

Tests cover the Runware client (retry/error mapping/contract drift), storage crash-consistency, path-safety guards, the gallery's HTTP surface, an in-memory MCP protocol round-trip, and stdio purity (nothing but JSON-RPC may touch stdout).

推荐服务器

Baidu Map

Baidu Map

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

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

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

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

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

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

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

官方
精选
本地
TypeScript
VeyraX

VeyraX

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

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

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

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

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

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

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

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选