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

> **Status notice: Kling 5.0 is an unconfirmed watchlist item.** Kuaishou has not announced a Kling 5.0 model, and [Muapi](https://muapi.ai) has no Kling 5.0 endpoint. This repository does not claim any Kling 5 specs, pricing or availability. What it does today is expose the **live Kling 4.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/kling-5](https://muapi.ai/kling-5) for status.

An [MCP](https://modelcontextprotocol.io) server that lets Claude Desktop, Cursor, and any MCP-compatible client generate Kling video 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/kling-4](https://muapi.ai/kling-4).

## Related Projects

- [Kling-5-API](https://github.com/Anil-matcha/Kling-5-API): Python client and examples for the same endpoints (Kling 5.0 watchlist).
- [Kling-4.0-Flash-API](https://github.com/Anil-matcha/Kling-4.0-Flash-API): Python SDK and examples for Kling 4.0 and Kling 4.0 Flash.
- [kling-5-comfyui](https://github.com/Anil-matcha/kling-5-comfyui) and [n8n-nodes-kling-5](https://github.com/Anil-matcha/n8n-nodes-kling-5): sibling ComfyUI nodes and n8n nodes.
- [Open-Generative-AI](https://github.com/Anil-matcha/Open-Generative-AI): open-source studio and model hub for generative image and video.

## Tools

| Tool | What it does | Default Muapi endpoint |
| --- | --- | --- |
| `kling_text_to_video` | Text prompt to video | `kling-4.0-text-to-video` |
| `kling_keyframe_to_video` | Animate a first frame; optional `keyframe_urls` and `last_image` | `kling-4.0-keyframe-to-video` |
| `kling_reference_to_video` | Guide a video with reference images/videos | `kling-4.0-reference-to-video` |
| `kling_get_result` | Check or wait for a request (`request_id`) | `GET /predictions/{request_id}/result` |

Parameters (current Kling 4.0 contract): `aspect_ratio` (`16:9`, `9:16`, `1:1`, `21:9`; reference-to-video also accepts `auto`; not used by keyframe-to-video), `resolution` (`720p`, `1080p`, `4k`), `dynamic_range` (`sdr`, `hdr`), `duration` (3 to 30 seconds). Reference-to-video needs at least one `images_list` (max 10) or `videos_list` (max 5) entry and accepts `keep_original_sound`.

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

## Install

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

### Claude Desktop

Add to `claude_desktop_config.json`:

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

### Cursor

Add to `~/.cursor/mcp.json` (or the project's `.cursor/mcp.json`):

```json
{
  "mcpServers": {
    "kling": {
      "command": "python",
      "args": ["/absolute/path/to/kling-5-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 |
| `KLING_MODEL` | `kling-4.0` | Slug prefix; endpoints become `<prefix>-text-to-video`, `<prefix>-keyframe-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 Kling 5.0:** if Muapi later publishes a Kling 5.0 model, setting `KLING_MODEL=kling-5.0` is the expected way to use it. That slug naming is an **unverified assumption**, not a confirmed endpoint, and a Kling 5 model may take different parameters than the Kling 4.0 schema enforced here. Until Muapi lists it, leave the default.

## Raw API equivalent

```bash
curl -X POST https://api.muapi.ai/api/v1/kling-4.0-text-to-video \
  -H "x-api-key: $MUAPI_API_KEY" -H "Content-Type: application/json" \
  -d '{"prompt":"A cinematic tracking shot at dusk","aspect_ratio":"16:9","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