# MAGI-2 MCP Server

> Let an AI agent create MAGI-2 videos for you. Add one remote MCP server with your API key, then ask for a clip in plain language; the agent submits the task, waits and returns the video link.

- Web page: https://magi2.studio/docs/mcp
- REST base URL: https://magi2.studio/v1
- MCP endpoint: https://magi2.studio/mcp
- All developer docs in one file: https://magi2.studio/docs/llms-full.txt

The MCP server uses the same API key, credits and limits as the REST API. Each tool call is a normal API request, so every task also appears in your API call logs.

- Transport: Streamable HTTP (stateless, JSON responses)

## Set up in three steps

### 1. Get an API key

Create a key in the dashboard. Use a separate key for agents so their tasks are easy to tell apart in the logs. Open API keys: https://magi2.studio/dashboard/api-keys (sign-in required)

### 2. Add the server to your client

Pick your client and paste the config, replacing YOUR_API_KEY with your key.

#### Claude Code

```bash
claude mcp add --transport http magi2 https://magi2.studio/mcp --header "Authorization: Bearer YOUR_API_KEY"
```

#### Cursor (`~/.cursor/mcp.json`)

```json
{
  "mcpServers": {
    "magi2": {
      "url": "https://magi2.studio/mcp",
      "headers": { "Authorization": "Bearer YOUR_API_KEY" }
    }
  }
}
```

#### VS Code (`.vscode/mcp.json`)

```json
{
  "servers": {
    "magi2": {
      "type": "http",
      "url": "https://magi2.studio/mcp",
      "headers": { "Authorization": "Bearer YOUR_API_KEY" }
    }
  }
}
```

#### Codex (`~/.codex/config.toml`)

Codex reads the key from the environment variable named in bearer_token_env_var.

```toml
# export MAGI2_API_KEY=YOUR_API_KEY

[mcp_servers.magi2]
url = "https://magi2.studio/mcp"
bearer_token_env_var = "MAGI2_API_KEY"
```

#### Windsurf (`~/.codeium/windsurf/mcp_config.json`)

```json
{
  "mcpServers": {
    "magi2": {
      "serverUrl": "https://magi2.studio/mcp",
      "headers": { "Authorization": "Bearer YOUR_API_KEY" }
    }
  }
}
```

#### Claude Desktop (`claude_desktop_config.json`)

Claude Desktop connects to remote servers through the mcp-remote bridge (requires Node.js).

```json
{
  "mcpServers": {
    "magi2": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://magi2.studio/mcp", "--header", "Authorization:${MAGI2_AUTH}"],
      "env": { "MAGI2_AUTH": "Bearer YOUR_API_KEY" }
    }
  }
}
```

### 3. Ask for a video

Restart the client if needed, then try a request like this:

> Use MAGI-2 to make a 6-second 9:16 clip of a barista pouring latte art in slow motion, with café ambience, and give me the video link when it is done.

## Tools

### magi2_generate_video

Creates a video task and returns its task_id and the credits charged. The video is not in this response: the agent polls magi2_get_task.

| Argument | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `prompt` | `string` | no | — | Shot description: subject, action, camera, style and sound. Up to 15,000 characters. Optional only with first_frame_url. |
| `duration` | `integer` | no | `5` | Whole seconds, 4–30. |
| `aspect_ratio` | `string` | no | `16:9` | 16:9, 9:16, 1:1, 4:3, 3:4 or 21:9. Ignored with first_frame_url. |
| `generate_audio` | `boolean` | no | `true` | Synchronized audio on or off. |
| `first_frame_url` | `string` | no | — | Public image URL used as the first frame. |
| `last_frame_url` | `string` | no | — | Public image URL used as the last frame; needs first_frame_url. |
| `image_urls` | `string[]` | no | — | Up to 10 public reference image URLs. |
| `video_urls` | `string[]` | no | — | Up to 5 public reference video URLs. |
| `audio_urls` | `string[]` | no | — | Up to 5 public reference audio URLs. |
| `seed` | `integer` | no | — | Optional integer seed for more repeatable results. |

### magi2_get_task

Returns IN_PROGRESS, SUCCESS (with the MP4 URL) or FAILED (with the reason; credits refunded).

| Argument | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `task_id` | `string` | yes | — | The task_id returned by magi2_generate_video. |

### magi2_list_tasks

Lists recent tasks for this API key with status, credits and video URLs, so an agent can find a task it lost track of.

| Argument | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `page` | `integer` | no | `1` | Page number. |
| `limit` | `integer` | no | `10` | Tasks per page, 1–100. |

## How a request runs

1. The agent calls magi2_generate_video once. Credits are charged and a task_id comes back within seconds.
2. The agent calls magi2_get_task every 20–30 seconds. Most clips are ready within a few minutes.
3. On SUCCESS the agent returns the MP4 link; on FAILED it reports the reason and the credits are refunded automatically.

## Pricing

Same as the REST API: 18 credits per second of 1080p output in every mode. A 5-second clip is 90 credits and a 10-second clip is 180 credits.

Full pricing in the API reference: https://magi2.studio/docs.md · Buy credits: https://magi2.studio/pricing

## Limits and good practice

- Inputs must be public http(s) URLs; agents cannot attach local files directly.
- Every magi2_generate_video call is billed. Tell your agent not to resubmit while a task is still IN_PROGRESS.
- The server is stateless (Streamable HTTP, JSON responses). No sessions or server-sent events are needed.

## FAQ

### Which clients are supported?

Any MCP client that supports remote HTTP servers with custom headers, including Claude Code, Cursor, VS Code, Codex and Windsurf. Claude Desktop works through mcp-remote.

### Is the MCP server free?

Connecting and listing tools is free. Generating videos uses credits from the same balance as the API and the studio.

### Can I send the key in a different header?

Yes. Authorization: Bearer YOUR_API_KEY is preferred, and an x-api-key header is also accepted.

### Where can I see what my agent generated?

In the API call logs in your dashboard. Pick the key the agent uses to see every request, status, cost and video.

---

MAGI-2 is a video model published by Sand.ai. Magi2 Studio is an independent service that runs it through a third-party API provider; it is not operated by, affiliated with or endorsed by Sand.ai.
