> ## Documentation Index
> Fetch the complete documentation index at: https://docs.meigen.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Install MCP Plugin

> Install MeiGen MCP for Claude Code, Cursor, VS Code, Windsurf, Codex CLI, Hermes Agent, or OpenClaw in minutes. Generate images and videos with GPT Image 2, Midjourney V8.1, Seedance 2.0, Veo 3.1, and more. Open-source, credit-based.

## Prerequisites

* **Node.js 18+** installed
* At least one generation provider (for `generate_image` / `generate_video`):
  * **MeiGen Cloud** — an API key from [meigen.ai](https://www.meigen.ai) (Settings → API Keys)
  * **ComfyUI** — a running ComfyUI server ([installation guide](https://github.com/comfyanonymous/ComfyUI))
  * **OpenAI-Compatible API** — your own key from any provider (Together AI, Fireworks AI, OpenAI, etc.)

<Tip>
  You don't need a provider to get started. Gallery search, prompt enhancement, and inspiration tools work without any API key.
</Tip>

***

## Installation

### Claude Code Plugin (Recommended)

<Steps>
  <Step title="Install the plugin">
    ```bash theme={null}
    # Add the plugin marketplace
    /plugin marketplace add jau123/MeiGen-AI-Design-MCP

    # Install
    /plugin install meigen@meigen-marketplace
    ```

    **Restart Claude Code** after installation (close and reopen, or open a new terminal tab).
  </Step>

  <Step title="Configure a provider">
    Start a new Claude Code session and run `/meigen:setup`. The setup wizard will guide you through provider selection and API key configuration on macOS, Linux, and Windows.

    Alternatively, set environment variables directly (see [Provider Configuration](#provider-configuration) below).
  </Step>

  <Step title="Start using it">
    Ask Claude to generate images or videos naturally:

    * *"Generate a minimalist logo for a coffee shop"*
    * *"Animate this photo into a 5-second clip"*
    * *"Search the gallery for cyberpunk cityscapes"*
    * *"Enhance this prompt: a cat in space"*
  </Step>
</Steps>

### Cursor / VS Code / Windsurf / Roo Code

One command writes the right MCP config file for each editor:

```bash theme={null}
npx meigen init cursor      # writes .cursor/mcp.json
npx meigen init vscode      # writes .vscode/mcp.json
npx meigen init windsurf    # writes ~/.codeium/windsurf/mcp_config.json
npx meigen init roo         # writes .roo/mcp.json
npx meigen init claude      # writes .mcp.json (Claude Code project-level)
```

After the config is written, set `MEIGEN_API_TOKEN` in your shell and restart the host. On hosts that don't support the `/meigen:setup` slash command, add the token to the `env` block of the meigen server entry directly.

### OpenAI Codex CLI

Codex uses TOML. Add to `~/.codex/config.toml`:

```toml theme={null}
[mcp_servers.meigen]
command = "npx"
args = ["-y", "meigen@latest"]

[mcp_servers.meigen.env]
MEIGEN_API_TOKEN = "meigen_sk_..."
```

### Hermes Agent (NousResearch)

Hermes is a first-class MCP client. Add to `~/.hermes/config.yaml`:

```yaml theme={null}
mcp_servers:
  meigen:
    command: "npx"
    args: ["-y", "meigen@latest"]
    env:
      MEIGEN_API_TOKEN: "meigen_sk_..."
    timeout: 600          # video generation can take 5–10 min
    connect_timeout: 120  # first npx download can be slow
```

<Warning>
  The `timeout: 600` and `connect_timeout: 120` overrides are important — Hermes defaults (120s / 60s) are tuned for short-running tools and will time out on video generation or first-run npx downloads.
</Warning>

### Standalone CLI (no MCP host required)

For shell scripts, CI pipelines, or anyone who wants AI image generation without an MCP host:

```bash theme={null}
# Auth once
export MEIGEN_API_TOKEN=meigen_sk_...

# Generate
npx meigen gen --prompt "a calico cat in a sunlit kitchen"

# With a specific model + aspect ratio
npx meigen gen -p "logo design" -m midjourney-v8.1 -r 1:1

# With a reference image (local path auto-uploaded)
npx meigen gen -p "product hero shot" --ref ~/Desktop/bottle.jpg

# Submit only — print generationId without polling (good for CI)
npx meigen gen -p "..." --no-wait

# Machine-readable output (good for jq pipes)
npx meigen gen -p "..." --json | jq -r '.imageUrls[0]'
```

Generated images save to `~/Pictures/meigen/` by default — see [Output Directories](#output-directories) to change where files land.

### OpenClaw

Install the full plugin from [ClawHub](https://clawhub.ai/plugins/meigen-ai-design) (includes commands, skills, and MCP server):

```bash theme={null}
openclaw bundles install clawhub:meigen-ai-design
```

Or install only the skill (no commands/agents):

```bash theme={null}
npx clawhub@latest install creative-toolkit
```

<Note>
  OpenClaw uses the [Agent Skills](https://agentskills.io) open standard. No MCP configuration needed — the skill handles everything.
</Note>

### Other MCP-Compatible Hosts

For any host that consumes stdio MCP, add this to its config file:

```json theme={null}
{
  "mcpServers": {
    "meigen": {
      "command": "npx",
      "args": ["-y", "meigen@latest"],
      "env": {
        "MEIGEN_API_TOKEN": "meigen_sk_..."
      }
    }
  }
}
```

***

## Provider Configuration

Configure one or more providers. When multiple are available, the plugin selects in order: MeiGen → ComfyUI → OpenAI-compatible. You can override this per-request.

### MeiGen Cloud

The easiest way to get started. MeiGen's hosted API gives you image and video models from OpenAI, Google, ByteDance, Midjourney, xAI, Black Forest Labs, Alibaba, and Agnes — no GPU required. Call `list_models` for the current lineup, or see the [model comparison](/en/features/models) for capabilities and pricing.

| Variable           | Value                                   |
| ------------------ | --------------------------------------- |
| `MEIGEN_API_TOKEN` | Your API key starting with `meigen_sk_` |

Get your API key: sign in at [meigen.ai](https://www.meigen.ai) → click your avatar → **Settings** → **API Keys** → create a new key.

<Warning>
  API keys can only use **purchased credits**, not daily free credits. Ensure your account has purchased credits before generating via the plugin.
</Warning>

### Bring Your Own API (OpenAI-Compatible)

Connect **any** image generation API that follows the OpenAI format — Together AI, Fireworks AI, DeepInfra, SiliconFlow, OpenAI, or your own endpoint.

| Variable          | Value                                              |
| ----------------- | -------------------------------------------------- |
| `OPENAI_API_KEY`  | Your API key from the provider                     |
| `OPENAI_BASE_URL` | API endpoint (e.g., `https://api.together.xyz/v1`) |
| `OPENAI_MODEL`    | *(Optional)* Model name at your provider           |

Set `OPENAI_BASE_URL` to point to your provider's endpoint. If omitted, defaults to OpenAI's API.

### ComfyUI (Local)

Run image generation on your own GPU with full control over models, samplers, and workflows. Free to use — no API key needed.

| Variable      | Value                                                     |
| ------------- | --------------------------------------------------------- |
| `COMFYUI_URL` | ComfyUI server address (default: `http://127.0.0.1:8188`) |

**Requirements**:

1. ComfyUI must be running and accessible at the configured URL
2. You need at least one imported workflow template — see the [ComfyUI Guide](/en/mcp/comfyui)

<Note>
  ComfyUI runs serially: one image at a time.
</Note>

***

## Output Directories

Generated files are written to disk by both the MCP tools and the standalone CLI.

| Type   | Default location     | Override                  | Linux fallback     |
| ------ | -------------------- | ------------------------- | ------------------ |
| Images | `~/Pictures/meigen/` | `MEIGEN_OUTPUT_DIR`       | `XDG_PICTURES_DIR` |
| Videos | `~/Movies/meigen/`   | `MEIGEN_VIDEO_OUTPUT_DIR` | `XDG_VIDEOS_DIR`   |

Set these the same way as your provider variables — in the `env` block of your MCP config, or exported in your shell for CLI use.

***

## Verify Installation

After setup, ask your AI assistant:

> "List the available models"

If configured correctly, it will call the `list_models` tool and show models from all your configured providers.

***

## Usage

Once installed, ask your AI assistant in plain language — for example, "Generate a watercolor landscape, 16:9 aspect ratio". See the [overview](/en/mcp/overview) for the full list of tools.

***

## Troubleshooting

<AccordionGroup>
  <Accordion title="'No image generation providers configured'" icon="circle-exclamation">
    No provider is set up. On Claude Code, run `/meigen:setup` (interactive wizard). On other hosts (Cursor, Codex, Windsurf, Hermes Agent, etc.), add the env var to your MCP config file directly:

    * MeiGen: `MEIGEN_API_TOKEN`
    * OpenAI-compatible: `OPENAI_API_KEY`
    * ComfyUI: `COMFYUI_URL` (and import a workflow)

    Then restart the host.
  </Accordion>

  <Accordion title="'Insufficient credits' (MeiGen)" icon="circle-exclamation">
    API keys can only use purchased credits, not daily free credits. Purchase credits at [meigen.ai](https://www.meigen.ai).
  </Accordion>

  <Accordion title="ComfyUI connection refused" icon="circle-exclamation">
    1. Make sure ComfyUI is running (`python main.py` in the ComfyUI directory)
    2. Check that `COMFYUI_URL` matches the address shown when ComfyUI starts (default: `http://127.0.0.1:8188`)
    3. If running on a different machine, ensure the port is accessible
  </Accordion>

  <Accordion title="ComfyUI generation fails" icon="circle-exclamation">
    1. Open the ComfyUI web UI and check for error messages
    2. Use `comfyui_workflow view` to inspect the workflow nodes
    3. Ensure the checkpoint model referenced in the workflow is actually downloaded
    4. Try running the workflow manually in ComfyUI first
  </Accordion>

  <Accordion title="Plugin not showing in tool list" icon="circle-exclamation">
    1. Make sure Node.js 18+ is installed
    2. Try running `npx -y meigen` directly to check for errors
    3. Restart your editor
    4. Check that the MCP configuration JSON is valid
  </Accordion>

  <Accordion title="Generation timeout" icon="circle-exclamation">
    Generation times vary by model and provider. MeiGen Cloud image models typically finish in 5–60 seconds; video generation takes 1–8 minutes. ComfyUI depends on your GPU.

    Timeouts: `generate_image` waits up to 5 minutes, `generate_video` up to 8 minutes, and both the standalone CLI and ComfyUI up to 5 minutes.
  </Accordion>

  <Accordion title="Changes to config not taking effect" icon="circle-exclamation">
    After modifying `~/.config/meigen/config.json` or environment variables, you must restart your editor (or start a new Claude Code session) for changes to take effect.
  </Accordion>
</AccordionGroup>
