Skip to main content
Glama
README.md
# Wan 4.0 MCP Server (Wan 4 API, works today with Wan 3.0) for Claude, Cursor and any MCP client

> **Status notice: Wan 4.0 is an unconfirmed watchlist item.** Alibaba has not announced a Wan 4.0 model (Wan 3.0, launched 2026-08-24, is the latest), and [Muapi](https://muapi.ai) has no Wan 4.0 endpoint. This repository does not claim any Wan 4 specs, pricing or availability. What it does today is expose the **live Wan 3.0** video endpoints on Muapi as MCP tools, with the model slug prefix configurable so it can be pointed at a newer model if and when Muapi publishes one. Watch [muapi.ai/wan-4](https://muapi.ai/wan-4) for status.

An [MCP](https://modelcontextprotocol.io) server that lets Claude Desktop, Cursor, and any MCP-compatible client generate Wan video (Wan 4.0 API / Wan 4 API keyword, served by Wan 3.0 today) through one [Muapi](https://muapi.ai) API key. Get a key at [muapi.ai/access-keys](https://muapi.ai/access-keys). Live model page: [muapi.ai/wan-3](https://muapi.ai/wan-3).

## Related

- [Wan-3.0-API](https://github.com/Anil-matcha/Wan-3.0-API): Python client for Wan 3.0.
- [wan-3.0-comfyui](https://github.com/Anil-matcha/wan-3.0-comfyui): ComfyUI nodes for Wan 3.0.

## Tools

| Tool | Purpose | Muapi endpoint |
| --- | --- | --- |
| `wan_text_to_video` | Text prompt to video with synchronized audio | `wan3.0-text-to-video` |
| `wan_image_to_video` | Animate a source image; optional `last_image` end frame | `wan3.0-image-to-video` |
| `wan_reference_to_video` | Guide a video with reference images, videos and audio | `wan3.0-reference-to-video` |
| `wan_get_result` | Check or wait for a request (`request_id`) | `GET /predictions/{request_id}/result` |

Parameters (current Wan 3.0 contract): `resolution` (`480p`, `720p`, `1080p`), `aspect_ratio` (`adaptive`, `16:9`, `9:16`, `1:1`, `4:3`, `3:4`), `duration` (2 to 30 seconds), `thinking_mode`, `enable_audio`, `seed` (-1 for random). Reference-to-video needs at least one `images_list` (max 10), `videos_list` (max 5) or `audios_list` (max 5) entry.

Generation tools return immediately with a `request_id`; call `wan_get_result` until `status` is `completed`.

## Quick start

```bash
git clone https://github.com/Anil-matcha/wan-4-mcp.git
cd wan-4-mcp
pip install -r requirements.txt
export MUAPI_API_KEY=your_key
```

### Claude Desktop / Cursor

```json
{
  "mcpServers": {
    "wan": {
      "command": "python",
      "args": ["/absolute/path/to/wan-4-mcp/mcp_stdio.py"],
      "env": { "MUAPI_API_KEY": "your_key" }
    }
  }
}
```

### HTTP bridge / Docker

`python mcp_server.py` starts a small FastAPI bridge on port 8000 (`/mcp/tools`, `/mcp/tools/{name}/call`, `/mcp/predictions/{id}`). A `Dockerfile` and `smithery.yaml` are included.

## Configuration

| Variable | Default | Purpose |
| --- | --- | --- |
| `MUAPI_API_KEY` | none (required) | Your Muapi key |
| `WAN_MODEL` | `wan3.0` | Slug prefix; endpoints become `<prefix>-text-to-video`, `<prefix>-image-to-video`, `<prefix>-reference-to-video` |
| `MUAPI_BASE_URL` | `https://api.muapi.ai/api/v1` | API base |
| `MUAPI_POLL_INTERVAL` / `MUAPI_POLL_TIMEOUT` | `5` / `900` | Polling seconds when waiting |

**About Wan 4.0:** if Muapi later publishes a Wan 4.0 model, setting `WAN_MODEL=wan-4.0` (or similar) is the expected way to use it. That slug naming (including `wan-4`) is an **unverified guess**, not a confirmed endpoint, and a Wan 4 model may take different parameters than the Wan 3.0 schema enforced here. Until Muapi lists it, leave the default. Wan 3.0 Prime is available with `WAN_MODEL=wan3.0-prime`.

## Raw API equivalent

```bash
curl -X POST https://api.muapi.ai/api/v1/wan3.0-text-to-video \
  -H "x-api-key: $MUAPI_API_KEY" -H "Content-Type: application/json" \
  -d '{"prompt":"A cinematic aerial shot of mist moving through a mountain valley at sunrise.","resolution":"720p","duration":5}'

curl https://api.muapi.ai/api/v1/predictions/<request_id>/result -H "x-api-key: $MUAPI_API_KEY"
```

## Tests

```bash
pip install -r requirements.txt
python -m unittest discover -s tests -t . -v
```

## License

MIT