Generate

MCP Server

Connect Claude/Codex to MachGen and generate from your AI agent.

MachGen runs a remote MCP server, so an AI assistant can generate images and video, edit past generations, and browse your history directly.

https://mcp.machgen.ai

Authenticate via OAuth

This works for Claude Desktop, Claude Code (CLI), Codex (both CLI and UI app).

Claude Desktop

Go to Settings -> Connectors -> Add.

Add https://mcp.machgen.ai as the URL.

Add MCP server to claude

On the next screen, approve the OAuth.

Claude OAuth

Authenticate via API Key

Note: Claude Desktop cannot use this approach. Use OAuth above.

Authenticate with the same API key you would normally use. Create one under Settings -> API keys; it looks like MGA_<key_id>:<secret>. The key needs the regular permission scope.

Claude Code

claude mcp add --transport http machgen https://mcp.machgen.ai \
  --header "Authorization: Bearer MGA_<key_id>:<secret>"

Run /mcp inside Claude Code to confirm the server shows as connected. The command saves the configuration without checking the credential, so a bad key shows up as failed here rather than at setup time.

What you can ask for

Once connected, ask in plain language - the assistant picks the tools:

  • "What video models can do 1080p at 16:9, and what would 5 seconds cost?"
  • "How much balance do I have left?"
  • "Generate a product shot of a ceramic mug on a linen backdrop."
  • "Use these reference images to create a new product shot."
  • "Make that warmer and move the mug left."
  • "Animate it for 5 seconds with a slow push-in."
  • "Save 1.25s through 3.75s of that video as a new clip."
  • "Quote the exact cost, then upscale that video to 4K."
  • "Download the finished audio as a file I can reuse."
  • "Give me a link I can send to the team."

Seedance 2.5 draft mode is requested on the REST body, not through these tools. See Seedance 2.5.

How generation works

Generation is asynchronous. The generate and upscale tools return a task_id right away and the assistant polls get_task until it finishes - images in seconds, video usually in minutes. You will see it check back a few times; that is expected.

When an image or video completes, supported chat clients render it inline in a compact media card with native video controls. Images also include vision content, so the assistant can inspect the result and iterate instead of describing it blind. A time-limited download link remains available as a fallback for clients that do not support rich MCP Apps.

Video upscaling has a separate workflow. The assistant first reads the available UPSCALE target tiers and engines, quotes the exact price for your owned source video, submits only after the quote, and polls the returned task. You can point it at a prior task id or MachGen asset URL; source resolution, frame rate, and duration are resolved by the server. Some UPSCALE surfaces accept only sources generated by specific models and tiers - list_models reports this as the surface's source_requirement (MiniMax H3's 2K regeneration takes only its own 768p outputs); any other source is rejected.

Tools

ToolWhat it does
list_modelsAvailable models with their exact sizes, aspect ratios and durations
get_priceWhat a generation would cost on your account, before you run it
check_balanceYour account's current spendable balance
upload_filesGet a browser upload link, then retrieve your uploaded image, video, and audio references
generate_imageGenerate an image from text or reference images supplied in sources
generate_videoText-, image-, reference-, or video-to-video
generate_audioSpeech, dialogue, sound effects, or music; sound effects scored to a video
extract_video_clipSave an exact subsection of an owned video as a reusable video, preserving audio
edit_imageEdit a previous image by task id, inheriting its model and size unless overridden
quote_video_upscaleExact cost to upscale an owned completed video to a supported tier
upscale_videoSubmit that source-aware video upscale
get_taskPoll a task; attaches the image or video for inline preview when done
get_tasksCheck up to 50 distinct task IDs in one call
get_task_paramsThe exact settings a past task used, to re-run with one change
list_historyYour past generations
get_assetA finished asset's media preview, URL, size, and image vision bytes
download_assetA finished image, video, or audio as embedded bytes or a raw HTTPS download manifest
create_asset_linkA shareable link that works without signing in

Use get_tasks to check 1-50 different task IDs at once. Results follow the order you provide. Empty lists, duplicate IDs, and more than 50 IDs are rejected. Tasks that do not exist or belong to another user return not_found for that item; your other results still return normally. Set wait_secs to wait up to 120 seconds for all accessible tasks to finish, then receive their current states. Images are omitted by default. With include_image=true, inline images share a 4 MiB raw image-byte budget; base64 encoding can make the response larger than 4 MiB. Use get_asset for previews and download links.

For YuE2 instrumental music, call generate_audio with kind="music", model="YuE2-3B", a style in prompt, and force_instrumental=true. You may provide lyrics or section tags in lyrics to help shape the track's flow and duration. Lyrics are used only to plan the music. For example, use [Intro], [Verse], [Chorus], and [Outro] to suggest a structure. Exact duration and section order are not guaranteed. This field is optional, with no minimum length and a maximum of 10,000 characters. Omit duration_secs. Vocal songs require 400 to 10,000 lyrics characters. Both modes return FLAC audio capped at approximately six minutes; audio reaching the cap is truncated and returned successfully.

Instrumental mode does not guarantee the absence of vocals. Generated tracks may still include singing or wordless vocalizations, such as humming. Use prompt for the musical style and lyrics for any planning lyrics.

Upload your own references

If your assistant cannot read local files or upload them directly, ask it for an upload link. Open the link, sign in to the same MachGen account connected to your assistant, and choose your images, videos, or audio. Return to the chat and tell your assistant when your files are ready. You do not need a terminal or have to copy file references yourself.

Drop several files onto the page or use Choose files. Each file shows a preview and upload status. If one fails, the others continue; use Try again beside the failed file to retry it. Images and audio can be up to 50 MiB each, and videos up to 256 MiB. HEIC is supported; PDFs are not.

The assistant calls upload_files to get the link and its session_id, then calls upload_files again with that ID to retrieve the completed files. Each file includes its name, media kind, and input_ref for generation. Files appear as soon as they finish uploading; you do not need to generate anything first.

Upload links accept files for two hours. Your assistant can retrieve the results for seven days after creating the link. References it has already retrieved remain usable. Select files on the upload page, including any you already attached to the chat.

Agents that can read files and perform HTTP uploads can still use create_upload followed by complete_upload for images.

Generate images with references

Use generate_image for both text-to-image and image-to-image generation. Provide prompt, model, and a supported height, and add reference images through the optional sources list. References can be your own images; they do not need to come from an earlier MachGen generation. Without sources, the tool generates from text alone.

Each entry in sources accepts:

  • Publicly accessible image URLs.
  • MachGen upload references in the form @input/<key>.
  • Your completed MachGen image task IDs or asset URLs.

A local file path is not an upload. Upload the image to MachGen first and use its returned reference, or provide an image URL. Inline data URLs are not supported by the asynchronous MCP generation tools.

With reference images, choose a model with an I2I surface in list_models. Its max_input_images is the total number of images allowed in sources. Models without I2I support and requests exceeding the limit are rejected.

Images keep their supplied order: entries in sources correspond to @image1, @image2, @image3, and so on. Describe each image's role in the prompt. For example, this MCP request uses one image for the subject and another for style guidance:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "generate_image",
    "arguments": {
      "model": "Nano-Banana-Pro",
      "height": 1024,
      "aspect_ratio": "1:1",
      "sources": [
        "https://example.com/subject.png",
        "https://example.com/style.png"
      ],
      "prompt": "Create a fox librarian. Use @image1 for the character and @image2 only for watercolor brushwork, paper texture, and colors."
    }
  }
}

Replace the example URLs with your accessible images. Style guidance is expressed through the prompt, not a dedicated style-control parameter. Results depend on the model; a reference may also influence composition or content. Style matching is not guaranteed.

Edit an existing image

Use edit_image to change a previous generation. Its source and optional extra_sources accept your completed image task IDs or MachGen asset URLs, rather than public image URLs, upload references, or data URLs. It inherits the source task's model and output size unless you override them. If that model does not support I2I, select an I2I model explicitly.

For a tools/call request, use these tool parameters:

{
  "name": "edit_image",
  "arguments": {
    "source": "<your-completed-image-task-id>",
    "prompt": "Keep the character and composition. Change the lighting to warm sunset light."
  }
}

Both tools return a task_id. Call get_task with that ID until the task completes or fails. Existing text-only generate_image calls and existing edit_image calls continue to work.

Generate videos with references

generate_video accepts src_image_urls, src_video_urls, and src_audio_urls. Use uploaded @input/... references, accessible media URLs, or your completed MachGen task IDs and asset URLs. Call list_models to check the model's supported surfaces, reference limits, and whether it requires a visual reference.

Use subject_to_image_ids, subject_to_video_ids, and subject_to_audio_ids to bind names in the prompt to zero-based positions in each source list. For mixed references, reference_order preserves their order across media types; each {type, index} entry identifies one source, and every source must appear exactly once. Audio references and subject bindings select reference-to-video.

For models with reference-video controls, reference_video_operation selects reference, edit, or extend. Use the operations advertised by list_models. For supported multi-shot models, set shot_type to customize and supply multi_prompt with matching shot_durations totaling duration_secs, or use intelligence to plan shots from a single prompt.

Every finished generation has a stable URL:

https://www.machgen.ai/api/v0/assets/<task_id>

That URL requires your credentials, so it opens in your signed-in browser but not for anyone else. To share a result, ask for a link - create_asset_link mints a time-limited URL (24 hours by default, up to 7 days) that works without signing in. It grants read access to that one asset and nothing else, so it is safe to paste into a message; your API key never leaves your machine.

To save or reuse the actual file, ask the assistant to download the asset. download_asset embeds files up to 8 MiB directly in the MCP result with their filename and MIME type. Larger files return a time-limited raw HTTPS download manifest without loading the whole file into the API server or injecting a video/audio URL into model context. The assistant saves it with its local file capability using the returned filename. Every path checks ownership and preserves the stored file type, original bytes, and filename. Clients that explicitly support MCP resources can still read the separately advertised machgen://assets/<task_id> resource, but downloads do not depend on automatic resource handling.

Rate limits

MCP calls draw on the same per-user budget as the REST API, so heavy tool use and heavy API use share one allowance.