mj drives Midjourney's web app from Go. It is a command-line tool and an MCP
server for AI agents. It uses your own Midjourney account. There is no Discord
bot and no account pool.
Under the hood it drives a real Camoufox browser through
gomoufox, so every request to
midjourney.com and the result CDN goes out the way a logged-in browser does.
That is the only path that clears Cloudflare.
Warning
Midjourney's Terms of Service prohibit automated access: "You may not use
automated tools to access, interact with, or generate Assets through the
Services." Accounts have been banned for it. mj is bring-your-own-account
only. Your account, your risk. It ships a conservative submit throttle, backs
off when the server rate-limits you, and refuses to generate until you pass
--i-understand once. Run it at low volume.
| You want to | Use |
|---|---|
| Generate images from a terminal or script | mj imagine "..." |
| Give an AI agent image tools | mj-mcp (25 tools) |
| Search and pull from the community gallery | mj search, mj explore |
| Edit an image (zoom out, pan, inpaint, restyle) | mj zoom, mj pan, mj vary-region, mj retexture |
| Watch a job render live | mj imagine "..." --watch |
| Share one warm browser across many calls | mj serve |
You need Go 1.26 or newer. On first run, gomoufox downloads a managed Camoufox browser (a Python venv plus a Firefox binary, about 300 to 660 MB). That happens once.
Install with Homebrew:
brew install ehmo/mj/mjOr install the two binaries with Go:
go install github.com/ehmo/mj/cmd/mj@latest
go install github.com/ehmo/mj/cmd/mj-mcp@latestOr build from a clone:
git clone https://github.com/ehmo/mj && cd mj
go build -o mj ./cmd/mj
go build -o mj-mcp ./cmd/mj-mcpCheck the toolchain:
mj doctormj login --i-understandA browser window opens. Sign in with Google or Discord, wait for the Create page
to load, then press Enter in the terminal. mj saves the session to a local
profile. If you have hasp, it also stores the
Firebase refresh token in your vault. The token never lands in mj's own config.
mj imagine "a vintage teal bicycle on a pink wall --ar 3:2" --wait --download ./outThis submits one job (a 4-image grid), waits for it to finish, and saves the
four cells plus the grid to ./out. Add --json for machine output.
Want to watch it render? Swap --wait for --watch:
mj imagine "a koi in dark water" --watch --download ./outYou get a live percentage from 0 to 100 over Midjourney's WebSocket.
Use the CLI when you drive Midjourney yourself, from a shell, a script, or a
cron job. Pipe --json into jq and you have a generation pipeline.
Use the MCP server when an agent should drive Midjourney. Claude (or any MCP client) gets 25 tools: generate, vary, upscale, animate, search, edit, download, and a raw escape hatch.
Use the daemon when you make many calls. Each one-off command cold-starts a browser, which costs about 4 to 6 seconds. A warm daemon shares one browser and one session, so calls drop to under a second.
for p in "red maple leaf" "blue spruce cone" "golden ginkgo"; do
mj imagine "$p, white background, studio light --ar 1:1" --wait --download ./botany --json \
| jq -r '.images[]'
doneEach line of output is a CDN URL. The files land in ./botany.
Register the server with Claude Code:
claude mcp add midjourney -- mj-mcpNow ask the agent in plain language: "Generate three logo options for a coffee
brand, then upscale the one with the cleanest type." The agent calls
midjourney_imagine, reads the result, and calls midjourney_upscale. See
docs/mcp.md for the full tool list and a worked transcript.
mj search "brutalist concrete interior, soft light" --limit 12 --download ./refs
mj explore --feed top_week --limit 20
mj styles # browse --sref style codesSearch runs Midjourney's semantic vector search. Every result carries the full prompt and flags that made it, so you can reproduce or remix it.
mj zoom photo.png "a wider establishing shot" --factor 2 --wait --download ./out
mj pan photo.png "more sky" --dir up --amount 0.5 --wait --download ./out
mj vary-region photo.png "a golden crown" --region 300,40,420,300 --wait --download ./out
mj retexture photo.png "oil painting, thick impasto" --ar 1:1 --wait --download ./outmj composites the edit the same way Midjourney's web editor does, then submits
it. The source can be a local file or a URL.
JOB=$(mj imagine "a paper boat on a calm pond --ar 16:9" --wait --json | jq -r .job_id)
mj video "$JOB" --index 1 --motion low --wait --download ./clipsVideos download in bounded-memory chunks, so a long clip does not balloon memory.
Every command takes --json. Data goes to stdout, progress and warnings go to
stderr, so pipes stay clean. Exit codes separate auth failures (3), job failures
(4), timeouts (5), and Cloudflare blocks (6) from generic errors (1).
Generate imagine vary upscale reroll video
Edit describe retexture zoom pan outpaint vary-region
Discover search explore likes styles profile uploads liked-styles
folders profiles queue moodboards
Jobs status wait watch history download
Account login logout account auth doctor
Daemon serve daemon
Raw api
Run mj help <command> for focused help on any of them. Full reference:
docs/cli.md.
Generation flags map straight to Midjourney parameters:
--ar W:H --version 7|8|8.1|niji 6|niji 7 --mode fast|relax|turbo --stealth
--stylize 0..1000 --chaos 0..100 --weird 0..3000 --quality 0.25|0.5|1|2|4
--seed N --no a,b --tile --stop 10..100 --style-raw --raw "..."
--sref U --sw N --sv N --oref U --ow N --cref U --cw N --profile ID
--image FILE|URL (repeatable; local files upload first)
--mode relax|turbo and --stealth need an eligible plan. mj checks your plan
before it submits, so you get a clear error instead of a wasted job.
mj-mcp speaks MCP over stdio, so it works with any MCP client.
Claude Code:
claude mcp add midjourney -- mj-mcpCodex, in ~/.codex/config.toml:
[mcp_servers.midjourney]
command = "mj-mcp"Cursor, Windsurf, or any other stdio client, in its MCP config:
{ "mcpServers": { "midjourney": { "command": "mj-mcp" } } }It exposes 25 tools:
imagine variation upscale reroll video (generate)
describe retexture zoom pan vary_region (edit)
search explore likes styles profile uploads (discover)
folders profiles queue moodboards (account)
status history account download api (jobs / raw)
It runs one generation at a time. It reads status, runs searches, and cancels
work while a generation is in flight, so the agent is never blocked. It refuses
to start until you have run mj login --i-understand.
An agent's input can be hostile (prompt injection from a web page or an image). The MCP surface is locked down for that:
imagearguments must be publichttpsURLs. Local paths are refused unless you setMJ_MCP_FILE_ROOT=/some/dir, and then only files under that directory. This stops "describe this image: /home/you/.ssh/id_rsa" from uploading your files to a third party.- URLs that point at private, loopback, or cloud-metadata hosts are blocked.
midjourney_api(the raw endpoint) is read-only unless you setMJ_MCP_ALLOW_RAW_WRITE=1.
Full tool reference, schemas, and an example agent session: docs/mcp.md.
mj serve # warm browser; keep it running (or background it)
mj daemon status # running (…/mj/daemon.sock)
mj search "cat" # ~0.3s instead of ~5s
mj daemon stopCommands route to the daemon when it runs and fall back to a one-off browser when it does not. The daemon throttles generations across every client, CLI and MCP together, through one session. That is faster and safer for your account than two clients submitting in parallel.
Set daemon_autostart: true in config (or MJ_DAEMON_AUTOSTART=1) and the first
command spawns a background daemon for you.
Automating Midjourney risks your account. mj does what it can to keep the risk
low:
- A minimum gap between submits (12s by default), enforced at one choke point so
even the raw
apitool cannot skip it. - Adaptive backoff: a
429grows the gap and a success shrinks it again. - One submit funnel through the daemon, shared by every client.
- The ToS gate (
--i-understand), stored once.
None of this makes automation safe. It makes it slower, which is the point. Set a
larger gap with --throttle or the throttle_secs config if you want more
headroom. Watch traffic with MJ_DEBUG=1, which logs every API call (method,
path, status, timing) with tokens redacted.
mj reads the Firebase refresh token from, in order:
MIDJOURNEY_FIREBASE_REFRESH_TOKEN(usehasp inject … -- mj …to broker it).- The local browser profile after
mj login.
It never writes the token to its own config. mj logout removes the local
session and deletes the stored token.
- docs/cli.md: every command, flag, and example.
- docs/mcp.md: every MCP tool, its schema, and an agent transcript.
- SECURITY.md: trust boundaries and how to report an issue.
- CONTRIBUTING.md: build, test, and the bar for changes.
MIT, copyright Wraxle LLC. See LICENSE.
Camoufox is MPL-2.0 and runs as a subprocess, downloaded at runtime, not vendored. gomoufox and playwright-go are MIT.
This is an unofficial, independent project. It is not affiliated with Midjourney, and Midjourney has not endorsed it.