- Home
- MCP servers
- Replicate Imagen 4
Replicate Imagen 4
- typescript
1
GitHub Stars
typescript
Language
5 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"pierrunoyt-replicate-imagen4-mcp-server": {
"command": "npx",
"args": [
"-y",
"https://github.com/PierrunoYT/replicate-imagen4-mcp-server.git"
],
"env": {
"REPLICATE_API_TOKEN": "YOUR_REPLICATE_API_TOKEN"
}
}
}
}You can run a Model Context Protocol (MCP) server that exposes Google's Imagen 4 Ultra model via Replicate. This setup automates image generation, downloads outputs locally, and makes it easy to generate images in multiple formats and aspect ratios while handling errors gracefully.
How to use
Use an MCP client to connect to the Replicate Imagen 4 MCP Server. You will send prompts to generate images, choose aspect ratios such as 1:1, 16:9, 9:16, 3:4, or 4:3, and receive both local file paths and original URLs for the generated images. The server automatically downloads generated images to a local images directory and returns detailed metadata about each prediction.
How to install
Prerequisites: Node.js 18 or higher and a Replicate API token.
Option 1: Portable Installation (Recommended) using npx
Install commands
{
"mcpServers": {
"replicate-imagen4": {
"command": "npx",
"args": ["-y", "https://github.com/PierrunoYT/replicate-imagen4-mcp-server.git"],
"env": {
"REPLICATE_API_TOKEN": "your_token_here"
}
}
}
}
Option 2: Local Installation
If you prefer to run locally, clone the project, install dependencies, and build.
Local installation commands
git clone https://github.com/PierrunoYT/replicate-imagen4-mcp-server.git
cd replicate-imagen4-mcp-server
npm install
npm run build
Set up environment and run
Set your Replicate API token as an environment variable. This token authorizes access to the Replicate service.
export REPLICATE_API_TOKEN=YOUR_REPLICATE_API_TOKEN
Starting the MCP server
Start the server through the MCP client you are using. The portable installation uses npx to fetch and run the server directly from its GitHub location.
Configuration
The server supports multiple image generation options, automatic local downloads, and dual access to both local file paths and original image URLs. You can adjust safety filtering levels, output formats, and aspect ratios as described in the available tools.
Troubleshooting
If the MCP server does not appear in your client, verify the path to the built index file, ensure the API token is set, and confirm you are using Node.js 18+. If image generation fails, check your Replicate token and credits, review your prompt for policy compliance, and retry with a different safety level.
Notes on usage
The MCP server returns both local file paths and original URLs for each generated image, and it stores images in a dedicated local images directory to enable offline access and persistent storage.
Example usage scenarios
Generate a photorealistic image of a landscape with a 16:9 aspect ratio and save it locally in the images directory.
Security and authentication
Keep your Replicate API token secure and do not expose it in code. Use environment variables to provide the token at runtime.
Available tools
imagen4_generate
Generate images using Imagen 4 Ultra with automatic local download and dual access to local paths and original URLs.
imagen4_generate_and_save
Generate images with a custom filename and automatic download to the local images directory, returning local paths and original URLs.
imagen4_get_prediction
Check the status and results of a specific Replicate prediction, including logs and errors.