Get the FREE Ultimate OpenClaw Setup Guide →

Image-Generation

This MCP server provides image generation capabilities using the Replicate Flux model.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio gongrzhe-image-generation-mcp-server npx -y @gongrzhe/image-gen-server \
  --env MODEL="alternative-model-name" \
  --env REPLICATE_API_TOKEN="your-replicate-api-token"

How to use

This MCP server provides image generation capabilities powered by the Replicate Flux model. The server exposes a tool named generate_image under the image-gen MCP server. To use it, you send a request via the MCP interface specifying the server_name image-gen, tool_name generate_image, and a set of arguments such as prompt, aspect_ratio, output_format, seed, and num_outputs. The tool will return URLs to the generated images. Typical usage involves providing a descriptive prompt and optional parameters to control size, style, and variety. If you don’t specify a model, the configured default Flux model (black-forest-labs/flux-schnell) will be used unless you override it with the MODEL environment variable.

Example usage in code: const result = await use_mcp_tool({ server_name: "image-gen", tool_name: "generate_image", arguments: { prompt: "A futuristic city at dusk", aspect_ratio: "16:9", output_format: "png", num_outputs: 2 } });

The tool returns an array of URLs pointing to the generated images. You can adjust the prompt and optional parameters to explore different visuals and aspect ratios until you reach a desirable result.

How to install

Prerequisites:

  • Node.js (recommended latest LTS) and npm installed on your system.
  • Access token for Replicate (see Get Your Replicate API Token in the README).

Installation steps:

  1. Install via NPX (no local setup required):

    • No local installation beyond running the MCP configuration with npx as shown in mcp_config.
  2. Optional local installation (preferred if you want to host locally):

# Global installation
npm install -g @gongrzhe/image-gen-server

# Or local installation inside a project
npm install @gongrzhe/image-gen-server
  1. Configure Claude Desktop (or your MCP runner) to use the NPX method (recommended) or the local node-based path as shown in the README configuration.
  • NPX configuration example is already provided in the mcp_config section above.
  • If you install locally, point the server to the built entry file (for example, /path/to/image-gen-server/build/index.js) in your Claude Desktop MCP config.
  1. Obtain and set your Replicate API token in the MCP config environment variables:
REPLICATE_API_TOKEN=your-replicate-api-token
MODEL=your-chosen-model (optional; defaults to black-forest-labs/flux-schnell)
  1. Ensure the MCP configuration JSON is saved to Claude Desktop (or your MCP runner) under the appropriate profile.

Additional notes

Notes and tips:

  • The default Flux model is black-forest-labs/flux-schnell. Override with the MODEL environment variable if you need a different model.
  • Required environment variable: REPLICATE_API_TOKEN. Without it, image generation requests will fail.
  • The generate_image tool supports prompt, seed, aspect_ratio, output_format (webp, jpg, png), and num_outputs (1-4). Adjust these to balance quality, speed, and variety.
  • If you encounter rate limits or API errors, verify your Replicate API token and the model name, and ensure your token has the necessary permissions.
  • When using NPX, you don’t need a local install; the server runs directly from npm’s registry. If you install locally, ensure your node path in the MCP config points to the built entry file.
  • For troubleshooting, check the MCP server’s logs for environment variable reads and the actual API calls to Replicate.

Related MCP Servers

Sponsor this space

Reach thousands of developers