Skip to main content
Glama

Media Creation MCP (media-creation-mcp)

Production-grade Model Context Protocol (MCP) server for multimodal AI image & video creation, supporting both local stdio and remote Streamable HTTP + OAuth 2.0 transports, stateful multi-shot storyboard continuity, idempotent async task execution, and AES-256-GCM encrypted credential storage.

面向多模态 AI 创作(文生图 / 图生视频 / 多参考图分镜编排)的生产级 MCP 服务端,兼容 Claude Code / Claude Desktop / ChatGPT / Codex / Cherry Studio 等主流 Agent 客户端。


Core Highlights

  • Dual Transport + Full OAuth 2.0 (stdio & Streamable HTTP)

    • Local mode (stdio) for CLI / desktop agents using environment-injected API keys.

    • Remote mode (--http) with OAuth 2.0 Dynamic Client Registration, PKCE (S256), CSRF-protected browser consent page, and strict Host/Origin validation.

  • Stateful Multi-Shot Continuity (prepare_story_shot)

    • Zero-cost, side-effect-free continuity planner that merges story brief, character reference sheets, and shot start/end states into deterministic generation payloads and returns next_shot_context.

    • Solves character & visual drift in long multi-shot video workflows by persisting shot context into local project files instead of relying on fragile chat memory.

  • Idempotent Async Execution & Key-Fingerprint Recovery

    • Enforces client-supplied operation_id deduplication to prevent accidental duplicate billing/generations on retries.

    • Binds async tasks to SHA-256 credential fingerprints so clients can resume polling (get_task) seamlessly across reconnects or credential alias renames.

  • Defense-in-Depth Security

    • AES-256-GCM Encrypted Vault (lib/store.mjs) with file locking (proper-lockfile), 0700 data directories, and 0600 file permissions; user API keys never leak to the LLM context.

    • SSRF & Attachment Guard (lib/attachment-download.mjs) using ipaddr.js DNS pinning + private IP range blocking + streaming byte limits.

    • Signed Ephemeral Uploads (create_upload_link / get_upload) for clients that cannot forward chat attachments directly to MCP tools.


Related MCP server: MiniMax MCP JS

Architecture

flowchart LR
  subgraph Clients["MCP Clients"]
    C1["Claude Code / Codex (stdio)"]
    C2["ChatGPT / Claude / Cherry Studio (HTTP + OAuth)"]
  end

  subgraph Server["media-creation-mcp (Node.js >= 22)"]
    T1["MCP Server & Tool Router\n(lib/server.mjs)"]
    OA["OAuth 2.0 + CSRF Consent\n(lib/oauth.mjs)"]
    CT["Storyboard Continuity Planner\n(lib/continuity.mjs)"]
    EN["Async Media Engine + Idempotency\n(lib/media.mjs)"]
    UP["Signed Upload & SSRF Guard\n(lib/uploads.mjs, attachment-download.mjs)"]
    ST["AES-256-GCM Vault + Lock\n(lib/store.mjs)"]
  end

  GW["OpenAI-Compatible Multimodal Gateway\n(Image / Video Models)"]

  C1 --> T1
  C2 --> OA --> T1
  T1 --> CT
  T1 --> EN
  T1 --> UP
  EN --> ST
  OA --> ST
  EN --> GW

MCP Tools & Prompts

Primitive

Type

Billing

Purpose

list_media_models

Tool

Free

Query available image/video models, pricing, and multi-reference limits per credential group

prepare_story_shot

Tool

Free

Merge brief, character references, and start/end states into next-shot generation params + next_shot_context

generate_image

Tool

Paid

Submit async image generation / multi-reference editing task with operation_id idempotency

generate_video

Tool

Paid

Submit async video generation task (first-frame or multi-reference) with operation_id idempotency

get_task

Tool

Read-only

Poll task progress and retrieve local file paths or signed ephemeral download links

create_upload_link

Tool (HTTP)

Free

Issue a 30-min signed web upload link (up to 14 images, 10 MB each) for clients without attachment forwarding

get_upload

Tool (HTTP)

Free

Resolve uploaded images into upload: references usable by generation tools

make_short_video

Prompt

Free

6-step guided workflow: storyboard → cost estimate → character sheet → per-shot continuity → review → delivery


Quick Start

Requirements

  • Node.js >= 22

Install & Run Tests

npm install
npm test

The test suite (test/*.test.mjs) covers:

  • media.test.mjs: async submission, idempotent operation_id, key-fingerprint recovery, artifact expiry

  • continuity.test.mjs: multi-shot character sheet & state carryover (prepare_story_shot)

  • references.test.mjs: multi-reference image limits, first-frame conflict validation, upload flows

  • clients.test.mjs: end-to-end stdio client & Streamable HTTP + OAuth 2.0 handshake + CSRF/Origin defense

  • safety.test.mjs: SSRF DNS/IP blocking, redirect guards, upload byte limits, disk capacity protection

1. Local stdio Mode (e.g. Claude Code / Claude Desktop)

export MEDIA_API_BASE_URL="https://your-gateway.example.com/v1"
export MEDIA_API_KEY="sk-your-key"
export MEDIA_MCP_DATA_DIR="$HOME/.local/share/media-creation-mcp"

node media-creation-mcp.mjs

Claude Code registration example:

claude mcp add --scope user --transport stdio media-creation -- node /abs/path/to/media-creation-mcp.mjs

2. Remote Streamable HTTP + OAuth Mode

export MEDIA_MCP_PUBLIC_URL="https://mcp.example.com"
export MEDIA_API_BASE_URL="https://api.example.com/v1"
export MEDIA_MCP_DATA_DIR="/var/lib/media-creation-mcp"
export MEDIA_MCP_STORAGE_KEY="$(openssl rand -base64 32)"
export PORT=18780

node media-creation-mcp.mjs --http

See deploy/README.md for systemd and Nginx reverse-proxy templates.


Project Structure

media-creation-mcp/
├── media-creation-mcp.mjs   # CLI entrypoint (stdio & --http server)
├── lib/
│   ├── server.mjs           # MCP tool/prompt definitions & Express HTTP router
│   ├── media.mjs            # Async media engine, idempotency, artifact lifecycle
│   ├── continuity.mjs       # Multi-shot storyboard state & character continuity planner
│   ├── oauth.mjs            # OAuth 2.0 provider, PKCE & CSRF-protected consent flow
│   ├── store.mjs            # AES-256-GCM encrypted JSON vault with file locking
│   ├── uploads.mjs          # Streaming multipart upload handler with byte caps
│   ├── attachment-download.mjs # SSRF-hardened attachment fetcher (DNS pinning + IP filter)
│   └── pages.mjs            # HTML UI templates for OAuth consent & uploads
├── test/                    # 6 end-to-end & security test suites (node --test)
└── deploy/                  # systemd & Nginx production deployment templates

License

MIT

Available Tools

5 tools
generate_image生成图片A
DestructiveIdempotent

用 Grok Imagine、Midjourney 或分组中其他按张计价的图片模型生成图片,会产生上游模型调用费用,返回 estimated_cost_usd。已适配型号可用 reference_images 编辑或融合图片,先查 list_media_models 的素材上限;部分 GPT Image 已接入多图。立即返回 task_id,用 get_task 取结果。Midjourney 按当前每次 4 张估价,实际扣费以使用记录为准;其他图片模型可选 1–4 张。只有用户明确要求创作时调用。

Inputs: model (required), prompt (required), operation_id (required), n, +7 more.

generate_video生成视频A
DestructiveIdempotent

用 Grok Imagine、Seedance 或 Kling 生成视频,会产生上游模型调用费用,返回 estimated_cost_usd。image 表示首帧;reference_images 表示不固定首帧的参考图。Grok、已适配 Seedance 与 Kling Omni 支持多参考图,数量和组合限制先查 list_media_models;Seedance 首帧与普通参考图不能混用。视频素材编辑暂未开放,上游编辑端点实测返回 HTTP 404;不要调用 video。长片先 prepare_story_shot,逐镜复用人物和衔接设定。立即返回 task_id,每约 5 秒用 get_task 续查。只有用户明确要求创作时调用。

Inputs: model (required), prompt (required), operation_id (required), image, +8 more.

get_task查询创作任务A
DestructiveIdempotent

查询已有 task_id,返回状态和作品的本地路径或限时下载链接。视频完成后查询可能触发现有网关的一次性结算;不创建新生成任务。重复查询不会重复提交。

Inputs: task_id (required).

list_media_models查看 AI 创作模型A
Read-onlyIdempotent

只读查询各密钥分组中当前可用的图片、视频模型及参数限制,不产生生成费用。

Inputs: no named parameters.

prepare_story_shot准备人物与分镜衔接A
Read-onlyIdempotent

不收费、不生成:按 AI 创作网页的规则,把项目设定、人物基准图、起止状态合并成下一镜生成参数。将返回的 next_shot_context 保存到本地项目文件并在后续镜头传回,避免依赖聊天记忆;素材不兼容时明确报错,不丢弃人物图。

Inputs: model (required), prompt (required), operation_id (required), n, +10 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 5 tools

    Disambiguation4/5

    The five tools split cleanly along lifecycle lines: discovery (list_media_models), planning (prepare_story_shot), execution (generate_image/generate_video), and polling (get_task). The only soft spots are generate_image vs generate_video, which share reference_images semantics, estimated_cost_usd, and task_id return behavior, requiring prose warnings (e.g. 'do not call video for editing') to keep them apart.

    Naming Consistency5/5

    All five names follow a strict verb_noun snake_case pattern (list_, prepare_, generate_, generate_, get_). Verb choice is also semantically consistent: list/get for reads, prepare for non-billable assembly, generate for billable creation, which reinforces the cost-safety contract.

    Tool Count5/5

    Five tools is well-scoped for a media generation server: one discovery tool, one cost-free planning tool, two generation tools split by modality, and one task poller. No tool looks redundant, and the small surface keeps the 'only call when the user asks to create' rule enforceable.

    Completeness4/5

    The core loop is closed: find models and limits, assemble shot parameters, submit a billable job, poll for the artifact. Minor gaps remain—there is no tool to list recent tasks, cancel/retry a job, or query usage/billing records, even though the descriptions defer actual charges to '使用记录' that no tool exposes.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers