Image-Generation-MCP-Server
by: GongRzhe
This MCP server provides image generation capabilities using the Replicate Flux model.
📌Overview
Purpose: To provide an MCP server that facilitates image generation using the Replicate Flux model.
Overview: This server enables users to generate images from text prompts by leveraging a robust machine learning model. It offers both npx and local installation options, accommodating various user preferences.
Key Features:
-
Image Generation Tool: Generates images based on text descriptions, allowing customization through parameters like aspect ratio, output format, and the number of images. This functionality enables users to create visually appealing content easily.
-
Flexible Installation Options: Users can choose between running the server directly via npx for quick access or performing a local installation for persistent use, catering to developers' different operational needs.
Image Generation MCP Server
This MCP server provides image generation capabilities using the Replicate Flux model.
Installation
NPX Method (No Local Setup Required)
You can use the package directly from npm without installing it locally:
# No installation needed - npx will handle it
Local Installation
If you prefer a local installation:
# Global installation
npm install -g @gongrzhe/image-gen-server
# Or local installation
npm install @gongrzhe/image-gen-server
Setup
Configure Claude Desktop
Edit your Claude Desktop configuration file:
- MacOS:
~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:
%APPDATA%/Claude/claude_desktop_config.json
NPX Configuration (Recommended)
Run the server directly from npm without needing local files:
{
"mcpServers": {
"image-gen": {
"command": "npx",
"args": ["@gongrzhe/image-gen-server"],
"env": {
"REPLICATE_API_TOKEN": "your-replicate-api-token",
"MODEL": "alternative-model-name"
},
"disabled": false,
"autoApprove": []
}
}
}
Local Installation Configuration
If you installed the package locally:
{
"mcpServers": {
"image-gen": {
"command": "node",
"args": ["/path/to/image-gen-server/build/index.js"],
"env": {
"REPLICATE_API_TOKEN": "your-replicate-api-token",
"MODEL": "alternative-model-name"
},
"disabled": false,
"autoApprove": []
}
}
}
Get Your Replicate API Token
- Sign up or log in at https://replicate.com.
- Go to https://replicate.com/account/api-tokens.
- Create a new API token.
- Copy the token and replace
your-replicate-api-token
in the MCP settings.
Environment Variables
REPLICATE_API_TOKEN
: Your Replicate API token for authentication (required).MODEL
: The Replicate model to use for image generation (optional, defaults to "black-forest-labs/flux-schnell").
Configuration Parameters
disabled
: Controls whether the server is enabled (false
) or disabled (true
).autoApprove
: Array of tool names that can be executed without user confirmation.
Available Tools
generate_image
Generates images using the Flux model based on text prompts.
Parameters
prompt
: Text description of the image to generate (required).seed
: Random seed for reproducible generation (optional).aspect_ratio
: Image aspect ratio (default: "1:1") (optional).output_format
: Output format - "webp", "jpg", or "png" (default: "webp") (optional).num_outputs
: Number of images to generate (1-4, default: 1) (optional).
Example Usage
const result = await use_mcp_tool({
server_name: "image-gen",
tool_name: "generate_image",
arguments: {
prompt: "A beautiful sunset over mountains",
aspect_ratio: "16:9",
output_format: "png",
num_outputs: 1
}
});
License
This project is licensed under the MIT License.