npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

multi-provider-imagegen-mcp

v1.1.1

Published

MCP server supporting multiple AI providers for image generation - OpenAI, Stability AI, Replicate, HuggingFace

Readme

MCP 多提供商图像生成服务器

npm version

This project provides a server implementation based on the Model Context Protocol (MCP) that supports multiple AI image generation providers including OpenAI, Stability AI, Replicate, and Hugging Face.

🎨 Features

支持的提供商

  • OpenAI: DALL-E 2, DALL-E 3, GPT-Image-1
  • Stability AI: Stable Diffusion XL, Stable Diffusion v2.1, Stable Diffusion v1.6
  • Replicate: Various open-source models including FLUX, SDXL, Playground v2.5
  • Hugging Face: Stable Diffusion models via Inference API

核心功能

  • 🖼️ text-to-image generation across multiple providers
  • ✏️ image-to-image editing (where supported)
  • 🔧 Unified API interface for all providers
  • ⚙️ Configurable via environment variables and command-line arguments
  • 📏 Support for various image sizes, styles, and quality settings
  • 💾 Saves generated/edited images to specified paths

Here's an example of generating an image directly in Cursor using the text-to-image tool integrated via MCP:

🚀 Quick Start

You can run the server directly from npm using npx:

# 基础用法(自动检测可用的提供商)
npx multi-provider-imagegen-mcp

# 指定提供商
npx multi-provider-imagegen-mcp --providers openai stability

# 指定模型
npx multi-provider-imagegen-mcp --models dall-e-3 stable-diffusion-xl-1024-v1-0

# 使用短名称
npx mpimg --providers openai stability replicate

📋 Prerequisites

🔧 Integration with Cursor

Integrate this multi-provider server with Cursor to access various image generation models:

  1. Open Cursor Settings:
    • Go to File > Preferences > Cursor Settings (or use Ctrl+, / Cmd+,)
  2. Navigate to MCP Settings:
    • Search for "MCP" and find "Model Context Protocol: Custom Servers"
  3. Add Custom Server:
    • Click "Edit in settings.json" and add configurations:

🎯 Example Configurations

Multi-Provider Setup (Recommended)

"mcpServers": {
  "multi-image-generator": {
    "command": "npx multi-provider-imagegen-mcp --providers openai stability replicate",
    "env": {
      "OPENAI_API_KEY": "your_openai_key",
      "STABILITY_API_KEY": "your_stability_key",
      "REPLICATE_API_TOKEN": "your_replicate_token"
    }
  }
}

Single Provider Setup

"mcpServers": {
  "openai-image-generator": {
    "command": "npx mpimg --providers openai --models dall-e-3",
    "env": {
      "OPENAI_API_KEY": "your_openai_api_key"
    }
  }
}

Advanced Configuration

"mcpServers": {
  "custom-image-generator": {
    "command": "npx multi-provider-imagegen-mcp --providers openai stability --models dall-e-3 stable-diffusion-xl-1024-v1-0",
    "env": {
      "OPENAI_API_KEY": "your_openai_key",
      "STABILITY_API_KEY": "your_stability_key"
    }
  }
}

After saving, the multi-provider image generation tools will be available in Cursor's MCP tool selection.

⚙️ Setup

  1. Clone the repository:

    git clone https://github.com/spartanz51/imagegen-mcp.git
    cd imagegen-mcp
  2. Install dependencies:

    pnpm install
    # or
    npm install
    # or
    yarn install
  3. Configure Environment Variables: Create a .env file in the project root:

    cp .env.example .env

    Edit the .env file and add your API keys (only add the ones you plan to use):

    # OpenAI (for DALL-E models)
    OPENAI_API_KEY=your_openai_api_key_here
        
    # Stability AI (for Stable Diffusion models)
    STABILITY_API_KEY=your_stability_api_key_here
        
    # Replicate (for various open-source models)
    REPLICATE_API_TOKEN=your_replicate_api_token_here
        
    # Hugging Face (for Inference API models)
    HUGGINGFACE_API_KEY=your_huggingface_api_key_here

🔨 Building

To build the TypeScript code into JavaScript:

pnpm run build
# or
npm run build
# or 
yarn build

This will compile the code into the dist directory.

🚀 Running the Server

Development Mode

pnpm run dev
# or
npx tsx src/index.ts [options]

Production Mode

node dist/index.js [options]

Command Line Options

--providers <provider1> <provider2> ...

Specify which providers to enable:

# Enable specific providers
node dist/index.js --providers openai stability

# Enable all available providers (with API keys)
node dist/index.js --providers openai stability replicate huggingface

--models <model1> <model2> ...

Specify which models to allow (applies to all enabled providers):

# Specific models
node dist/index.js --models dall-e-3 stable-diffusion-xl-1024-v1-0

# Combined with providers
node dist/index.js --providers openai stability --models dall-e-3

Auto-Detection

If no options are provided, the server automatically detects available providers based on environment variables:

node dist/index.js

The server will start and listen for MCP requests via standard input/output (StdioServerTransport).

🛠️ MCP Tools

The server exposes the following unified MCP tools that work across all providers:

text-to-image

Generates an image based on a text prompt using any supported provider.

Parameters:

  • text (string, required): The prompt to generate an image from
  • outputPath (string, required): Absolute path where the output file should be saved
  • model (enum, optional): The model to use (format: provider/model or model). Auto-detects provider if not specified
  • provider (enum, optional): The provider to use (openai, stability, replicate, huggingface). Auto-detected from model if not specified
  • size (enum, optional): Size of the generated image (e.g., 1024x1024, 1792x1024). Defaults to 1024x1024
  • style (enum, optional): Style of the image (vivid or natural). Supported by certain models like DALL-E 3
  • output_format (enum, optional): Format (png, jpeg, webp). Defaults to png
  • output_compression (number, optional): Compression level (0-100). Defaults to 100
  • moderation (enum, optional): Moderation level (low, auto). Defaults to low (OpenAI specific)
  • background (enum, optional): Background (transparent, opaque, auto). Defaults to auto
  • quality (enum, optional): Quality (standard, auto, high, medium, low). Defaults to auto
  • n (number, optional): Number of images to generate. Defaults to 1

Example Usage:

{
  "text": "A beautiful landscape with mountains and a lake",
  "outputPath": "/tmp/landscape.png",
  "model": "openai/dall-e-3",
  "size": "1024x1024",
  "style": "vivid"
}

image-to-image

Edits an existing image based on a text prompt and optional mask.

Parameters:

  • images (array, required): An array of file paths to local images
  • prompt (string, required): A text description of the desired edits
  • outputPath (string, required): Absolute path where the output file should be saved
  • mask (string, optional): File path of mask image (PNG). Transparent areas indicate where the image should be edited
  • model (enum, optional): The model to use (format: provider/model or model). Auto-detects provider
  • provider (enum, optional): The provider to use. Auto-detected from model if not specified
  • size (enum, optional): Size of the generated image. Defaults to 1024x1024
  • output_format (enum, optional): Format (png, jpeg, webp). Defaults to png
  • output_compression (number, optional): Compression level (0-100). Defaults to 100
  • quality (enum, optional): Quality settings. Defaults to auto
  • n (number, optional): Number of images to generate. Defaults to 1

Provider Support:

  • OpenAI: Supports DALL-E 2 and GPT-Image-1 for editing
  • Stability AI: Supports image-to-image with Stable Diffusion models
  • Replicate: Supports various image editing models
  • Hugging Face: Limited support (falls back to text-to-image for some models)

Returns:

Both tools return:

  • content: An array containing a text object with the path to the saved image file

Development

  • Linting: npm run lint or yarn lint
  • Formatting: npm run format or yarn format (if configured in package.json)

Contributing

Pull Requests (PRs) are welcome! Please feel free to submit improvements or bug fixes.