Image Generator MCP server

Enables AI assistants to create images using Replicate or Together AI's image generation models through a flexible tool that accepts parameters like prompt, width, height, and can be run locally or deployed as a Docker container.
Back to servers
Provider
GMKR
Release date
Mar 17, 2025
Language
TypeScript
Stats
3 stars

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.

Installation Options

You can run the MCP Image Generator either as a Docker container with an SSE endpoint or locally using stdio.

Docker Installation

  1. Clone the repository:

    git clone https://github.com/gmkr/mcp-imagegen.git
    cd mcp-imagegen
    
  2. Build and run the Docker container:

    docker build -f Dockerfile.server -t mcp-imagegen .
    docker run -p 3000:3000 mcp-imagegen
    

Local Installation

  1. Ensure you have Node.js installed

  2. Clone the repository:

    git clone https://github.com/gmkr/mcp-imagegen.git
    cd mcp-imagegen
    
  3. Install dependencies:

    pnpm install
    

Configuration

Docker/SSE Configuration

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"
      }
    }
  }
}

Local/stdio Configuration

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.

Usage

The server provides a tool called generate_image for creating images from text prompts.

Tool Parameters

  • prompt (string): The text prompt to generate an image for
  • width (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)

Environment Variables

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")

How to add this MCP server to Cursor

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.

Adding an MCP server to Cursor globally

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"
            ]
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later