midjourney-mcp
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@midjourney-mcpimagine a photorealistic dog playing in autumn leaves"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
midjourney-mcp
FastMCP server for Midjourney image generation via PiAPI, with a daily-USD cost cap, per-call audit log, and SSRF-safe image URL inputs.
Midjourney has no broadly available official API as of May 2026 (Enterprise application-only). This MCP wraps PiAPI's PAYG Midjourney surface — the most stable third-party wrapper at the time of build — behind one consistent tool surface that fits the same audit + safety patterns as the rest of the family (cloudflare-dns-mcp, godaddy-mcp, parse-mcp, etc.).
Why a peer MCP
Other Midjourney MCPs exist (AceDataCloud, z23cc, PiAPI's own TypeScript MCP). This one ships:
Daily USD cap. A single env var (
MIDJOURNEY_MCP_DAILY_USD_CAP) sets a hard ceiling on per-day image-gen spend. Cost-incurring tools refuse with a stableerror_class="rate_cap"once the projected day total exceeds cap.Per-call 4-field audit log (
execution_time_ms/io/token_usage/error_class) at~/.claude/midjourney-mcp/audit.log.jsonl, with actual PiAPI credit consume rolled in on completion.SSRF-safe image URL inputs on
describe+blendvia mycelium-securitysanitize_or_raise+assert_public_ip. Defense in depth — refuses private / link-local / cloud metadata service hosts before forwarding.sanitize_error()strip patterns on every error payload — X-API-Key, Bearer tokens, api_key / secret / password / token patterns get redacted before crossing into model context.admin.envauto-load. Secrets live at~/.claude/midjourney-mcp/admin.env(chmod 600, gitignored), never inline in.mcp.json.
Install
cd ~/.claude/midjourney-mcp
python3 -m pip install --break-system-packages -r requirements.txtThen drop the API key into admin.env:
printf 'PIAPI_API_KEY=your-piapi-key-here\n' > ~/.claude/midjourney-mcp/admin.env
chmod 600 ~/.claude/midjourney-mcp/admin.envSign up at https://piapi.ai/ if you need a key. PAYG starts at ~$0.01 per
imagine task. Host-Your-Account ($8/seat/mo) is also supported — set the
daily cap to 0 (MIDJOURNEY_MCP_DAILY_USD_CAP=0) to disable cost tracking in
HYA mode.
Register in your project .mcp.json:
{
"mcpServers": {
"midjourney": {
"command": "python3",
"args": ["/Users/YOU/.claude/midjourney-mcp/server.py"],
"env": {}
}
}
}Then restart Claude Code.
Tools (11 total)
Read (no cost, no cap)
Tool | What it does |
| Verify the PiAPI key is set + return today's cap snapshot |
| Today's USD cap + per-tool cost estimates + default process_mode |
| Single poll for task status + output URLs |
| Block until terminal state |
| Scan the local audit log for recent task_ids |
Cost-incurring (cap-gated)
Tool | Estimated USD (fast mode) | What it does |
| $0.040 | 4-up grid from a text prompt |
| $0.040 | Regenerate variations off a grid (index 1-4 / high_variation / low_variation) |
| $0.010 | Isolate + upscale one grid image (index 1-4 / light / beta / 2x / 4x / subtle / creative) |
| $0.005 | 4 prompts from an input image (image-to-prompt) |
| $0.040 | Merge 2-5 images into a new 4-up grid |
Lifecycle
Tool | What it does |
| Cancel a non-terminal task |
Daily USD cap
Image generation is creative iteration. Draft+confirm on every call breaks the loop. Instead, every cost-incurring tool runs a cap check BEFORE the API call:
projected = spent_today_usd + estimated_call_usd
if projected > MIDJOURNEY_MCP_DAILY_USD_CAP:
refuse with error_class="rate_cap"Spent-today tracks the calendar day at a configurable UTC offset (default
-5; override via MIDJOURNEY_MCP_TZ_OFFSET_HOURS=-8 for US Pacific
Standard, 1 for Central European, etc.). Cap resets at midnight in that
offset. Estimates drive the cap (conservative pre-flight); actual PiAPI
credit consume is backfilled from meta.usage.consume on task completion
and lands in the audit log.
Default cap: $5.00/day. Override via env: MIDJOURNEY_MCP_DAILY_USD_CAP=20.00.
Set to 0 to disable (e.g. HYA mode with flat $8/mo billing).
Typical flow
# 1. Submit an imagine
imagine(prompt="a quiet kitchen at dawn, soft window light, film grain --ar 3:2", aspect_ratio="3:2")
# -> {"task_id": "tk_abc...", "status": "pending", ...}
# 2. Wait for it
wait_for_task(task_id="tk_abc...", timeout_seconds=180)
# -> {"status": "completed", "task": {"output": {"image_url": "...", "image_urls": [...]}}}
# 3. Upscale the best one (say grid position 2)
upscale(origin_task_id="tk_abc...", index="2")
# -> {"task_id": "tk_xyz...", ...}
wait_for_task(task_id="tk_xyz...")
# Or vary instead of upscale:
variation(origin_task_id="tk_abc...", index="3", prompt="<same prompt, tweak>")Audit log
Every tool call writes one JSONL line at ~/.claude/midjourney-mcp/audit.log.jsonl:
{
"ts": 1737842400,
"tool": "imagine",
"execution_time_ms": 1230,
"io": {"input": {"prompt_chars": 47, "aspect_ratio": "3:2"}, "output": {"task_id": "tk_abc...", "status": "pending"}},
"token_usage": {},
"error_class": "none",
"extra": {"task_id": "tk_abc...", "usd_estimate": 0.04}
}Search by tool, date, error_class, task_id. Useful for cost attribution + bug
triage. Override the path via MIDJOURNEY_MCP_AUDIT_LOG.
Process modes
PiAPI translates process_mode to Midjourney's plan-level modes:
relax— slowest, cheapest, no GPU minutes consumed on official MJ plansfast— default, normal-quality GPU timeturbo— fastest, premium GPU time, ~2× cost
Override default via env: MIDJOURNEY_MCP_PROCESS_MODE=fast (default).
Override per-call via the process_mode argument on any tool.
Aspect ratios
Pass aspect_ratio to imagine / variation. Common values:
1:1(square, default)3:2,2:3(classic photo)16:9,9:16(cinema / portrait phone)4:3,3:4(older monitor / portrait)21:9(ultra-wide)
PiAPI also accepts Midjourney's --ar W:H flag in the prompt itself; either
works, but aspect_ratio is cleaner.
Configuration reference
Env var | Default | Purpose |
| (required) | PiAPI API key. Auto-loaded from |
|
| Override for mocking / testing. |
|
| Daily USD spend cap. |
|
| Default mode if not specified per-call. |
|
| Audit log path. |
|
| Daily spend tracker path. |
Related MCPs
Same author, same install path (~/.claude/<name>-mcp), same safety patterns:
whatsapp-mcp — WhatsApp Web bridge with draft+confirm sends
imessage-mcp — iMessage with Whisper voice transcription
slack-mcp — Multi-workspace Slack with draft+confirm
substack-mcp — Notes + drafts + post management
parse-mcp — Multi-backend document parser
godaddy-mcp — GoDaddy DNS with draft+confirm
cloudflare-dns-mcp — Cloudflare DNS with draft+confirm
finance-mcp — Plaid-backed personal finance
License
MIT.
Built by Adelaida Diaz-Roa. Full install or team version at diazroa.com.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/adelaidasofia/midjourney-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server