MAGI-2 MCP Server: Generate 30s Videos in Claude, Cursor & Codex
Connect your Magi2AI account to Claude and ask for a MAGI-2 video in plain words. Same credits, same My Videos.
- Create API key
Step 1
Create an API key
Open your account page and create a key. It starts with m2k_ and is shown only once, so copy it right away.
Step 2
Add Magi2AI as a custom connector
Open the pre-filled connector form, then add an Authorization header with your key under Advanced settings.
Add to Claude(opens in a new tab)Header name
AuthorizationHeader value
Bearer m2k_YOUR_API_KEYStep 3
Ask for a video
Try: “Make a 10-second 16:9 MAGI-2 video of a lighthouse in a storm, with thunder and waves.” The agent checks the price, submits and returns the video link when it is ready, usually in 3-10 minutes.
- Create API key
Step 1
Create an API key
Open your account page and create a key. It starts with m2k_ and is shown only once, so copy it right away.
Step 2
Add the server to Cursor
Paste this into ~/.cursor/mcp.json (or .cursor/mcp.json in a project) and replace the key placeholder.
Cursor
{ "mcpServers": { "magi2": { "url": "https://magi2ai.video/api/mcp", "headers": { "Authorization": "Bearer m2k_YOUR_API_KEY" } } } }Step 3
Ask for a video
Try: “Make a 10-second 16:9 MAGI-2 video of a lighthouse in a storm, with thunder and waves.” The agent checks the price, submits and returns the video link when it is ready, usually in 3-10 minutes.
- Create API key
Step 1
Create an API key
Open your account page and create a key. It starts with m2k_ and is shown only once, so copy it right away.
Step 2
Add the server to Claude Code
Run this command in your terminal and replace the key placeholder.
Claude Code
claude mcp add --transport http magi2 https://magi2ai.video/api/mcp \ --header "Authorization: Bearer m2k_YOUR_API_KEY"Step 3
Ask for a video
Try: “Make a 10-second 16:9 MAGI-2 video of a lighthouse in a storm, with thunder and waves.” The agent checks the price, submits and returns the video link when it is ready, usually in 3-10 minutes.
- Create API key
Step 1
Create an API key
Open your account page and create a key. It starts with m2k_ and is shown only once, so copy it right away.
Step 2
Add the server to Codex
Add this to ~/.codex/config.toml and export your key as MAGI2_API_KEY.
Codex
# ~/.codex/config.toml [mcp_servers.magi2] url = "https://magi2ai.video/api/mcp" bearer_token_env_var = "MAGI2_API_KEY" # shell export MAGI2_API_KEY="m2k_YOUR_API_KEY"Step 3
Ask for a video
Try: “Make a 10-second 16:9 MAGI-2 video of a lighthouse in a storm, with thunder and waves.” The agent checks the price, submits and returns the video link when it is ready, usually in 3-10 minutes.
MCP server URL
https://magi2ai.video/api/mcpWhat you can do with the MAGI-2 MCP
Everything the MAGI-2 generator on the website does, from inside your agent.
Text to video
Describe a scene and pick a length from 4 to 30 seconds and one of six aspect ratios. MAGI-2 handles multi-shot stories, camera moves, dialogue and sound effects.
First and last frame
Give a public image URL as the first frame, and optionally a last frame. The agent imports it and MAGI-2 animates between them.
Reference images and videos
Pass up to 10 reference images, or up to 5 videos you already generated on Magi2AI, and refer to them in the prompt as image 1 or video 1.
Balance, price and history
The agent checks your credits and the price before it submits, and can list your recent videos. Every video also shows up in My Videos on the website.
Use the MAGI-2 API from your own code
Prefer scripts or workflows? Call the same endpoints with your API key as a Bearer token: submit, poll, download.
curl
# 1. Submit (spends credits; reuse clientRequestId when retrying)
curl -s https://magi2ai.video/api/generation/video/generate \
-H "Authorization: Bearer $MAGI2_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "sandai/magi-2",
"prompt": "A red fox runs through fresh snow at sunrise, slow motion",
"duration": 4,
"resolution": "1080P",
"aspectRatio": "16:9",
"generateAudio": true,
"clientRequestId": "fox-001"
}'
# => {"ok":true,"data":{"requestId":"...","cost":24}}
# 2. Poll until status is "completed" (usually 3-10 minutes)
curl -s https://magi2ai.video/api/generation/video/REQUEST_ID \
-H "Authorization: Bearer $MAGI2_API_KEY"
# 3. Download data.outputs[0].url
curl -L -o fox.mp4 "VIDEO_URL_FROM_STEP_2"Python
import os, time, uuid, requests
BASE = "https://magi2ai.video"
HEADERS = {"Authorization": f"Bearer {os.environ['MAGI2_API_KEY']}"}
# 1. Submit; reuse the same clientRequestId if you retry
res = requests.post(f"{BASE}/api/generation/video/generate", headers=HEADERS, json={
"model": "sandai/magi-2",
"prompt": "A red fox runs through fresh snow at sunrise, slow motion",
"duration": 4,
"resolution": "1080P",
"aspectRatio": "16:9",
"generateAudio": True,
"clientRequestId": str(uuid.uuid4()),
}).json()
if not res["ok"]:
raise SystemExit(res["error"])
request_id = res["data"]["requestId"]
# 2. Poll every 15 s, give up after 20 minutes
for _ in range(80):
video = requests.get(f"{BASE}/api/generation/video/{request_id}", headers=HEADERS).json()["data"]
if video["status"] != "processing":
break
time.sleep(15)
# 3. Download
if video["status"] == "completed":
with open("fox.mp4", "wb") as f:
f.write(requests.get(video["outputs"][0]["url"]).content)
else:
print("Failed:", video["errorMessage"])Node.js
// Node 18+ (built-in fetch)
const BASE = "https://magi2ai.video";
const headers = {
Authorization: `Bearer ${process.env.MAGI2_API_KEY}`,
"Content-Type": "application/json",
};
// 1. Submit; reuse the same clientRequestId if you retry
const submit = await fetch(`${BASE}/api/generation/video/generate`, {
method: "POST",
headers,
body: JSON.stringify({
model: "sandai/magi-2",
prompt: "A red fox runs through fresh snow at sunrise, slow motion",
duration: 4,
resolution: "1080P",
aspectRatio: "16:9",
generateAudio: true,
clientRequestId: crypto.randomUUID(),
}),
}).then((r) => r.json());
if (!submit.ok) throw new Error(submit.error.message);
// 2. Poll every 15 s, give up after 20 minutes
let video;
for (let i = 0; i < 80; i++) {
video = (await fetch(`${BASE}/api/generation/video/${submit.data.requestId}`, { headers }).then((r) => r.json())).data;
if (video.status !== "processing") break;
await new Promise((r) => setTimeout(r, 15_000));
}
// 3. Result
console.log(video.status === "completed" ? video.outputs[0].url : video.errorMessage);MAGI-2 API pricing and limits
No separate API price: generations cost the same 6 credits per second as on the website.
6 credits / second
A 4-second video is 4 × 6 credits. Failed or timed-out videos are refunded automatically.
6 per minute
Up to 6 submissions per minute across all your keys.
3 at once
Up to 3 videos rendering at the same time per account.
Prepaid only
Credits are prepaid, so there is no surprise bill. Up to 5 active keys per account.
MAGI-2 MCP tools
Seven tools your agent can call. Tool descriptions are written for the model, so you rarely need to call them by name.
magi2_account_statusEmail, subscription, credit balance, price per second and your API limits.
magi2_get_modelMAGI-2 parameters: duration, aspect ratios, audio and the three input modes.
magi2_estimate_costPrice of a video of a given length, compared with your balance.
magi2_upload_imageImport an image from a public https URL to use as a frame or reference.
magi2_generate_videoSubmit a MAGI-2 video. Spends credits; retries are safe with the same request ID.
magi2_get_generationCheck a video and get its download URL when it is ready.
magi2_list_generationsList your recent videos, for example after a timed-out submission.
MAGI-2 MCP FAQ
How is this different from using the website?
How much does the MAGI-2 API cost?
Do I need a paid plan to use it?
How long does a video take?
What if my API key leaks?
Does it work with ChatGPT or Claude.ai without a key?
Can I use the videos commercially?
Are there content rules?
Start generating MAGI-2 videos from your agent
Create an API key, add the MCP server, and ask for your first video.