This MCP server enables image generation using Together AI's or Replicate's models through the Model Context Protocol. It provides a straightforward way to generate images from text prompts with configurable parameters.
You can run the MCP Image Generator either as a Docker container with an SSE endpoint or locally using stdio.
Clone the repository:
git clone https://github.com/gmkr/mcp-imagegen.git
cd mcp-imagegen
Build and run the Docker container:
docker build -f Dockerfile.server -t mcp-imagegen .
docker run -p 3000:3000 mcp-imagegen
Ensure you have Node.js installed
Clone the repository:
git clone https://github.com/gmkr/mcp-imagegen.git
cd mcp-imagegen
Install dependencies:
pnpm install
Create a configuration file for your MCP client:
{
"mcpServers": {
"imagegenerator": {
"url": "http://localhost:3000/sse",
"env": {
"PROVIDER": "replicate",
"REPLICATE_API_TOKEN": "your-replicate-api-token"
}
}
}
}
For local execution, use this configuration in your MCP client:
{
"mcpServers": {
"imagegenerator": {
"command": "pnpx",
"args": [
"-y",
"tsx",
"/path/to/mcp-imagegen/src/index.ts"
],
"env": {
"PROVIDER": "replicate",
"REPLICATE_API_TOKEN": "your-replicate-api-token"
}
}
}
}
Replace /path/to/mcp-imagegen
with the absolute path to your cloned repository and use your actual API credentials.
The server provides a tool called generate_image
for creating images from text prompts.
prompt
(string): The text prompt to generate an image forwidth
(number, optional): The width of the image to generate (default: 512)height
(number, optional): The height of the image to generate (default: 512)numberOfImages
(number, optional): The number of images to generate (default: 1)You can customize the server behavior with these environment variables:
PROVIDER
: Set to either "replicate" or "together" (default: "replicate")REPLICATE_API_TOKEN
: Your Replicate API token (required if using Replicate)TOGETHER_API_KEY
: Your Together AI API key (required if using Together)MODEL_NAME
: The model to use for image generation (default: "black-forest-labs/flux-schnell")There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.