OpenCode Integration with Midjourney MCP
📘 Overview:OpenCode MCP Overview →
You have just finished writing a README draft for a new feature in the terminal and need an accompanying image. Switching browsers, going to Discord, grabbing the Midjourney bot, and then downloading the image back to the terminal is very inefficient. After connecting to the Midjourney MCP Server, OpenCode can directly generate images based on contextual descriptions without leaving the terminal.
Midjourney MCP is suitable for creating product banners, social media posters, brand visuals, and series illustrations that require stylistic consistency.
¶ Obtain API Token
Before using the Midjourney MCP Server, you need to prepare an Ace Data Cloud API Token. OpenCode and Claude Code share a set of Tokens, and the acquisition process is the same:
- Open the Ace Data Cloud Console - Application List to obtain your API Token for backup.
- If you are not logged in or registered, you will be automatically redirected to the login page; after logging in or registering, you will be automatically returned to the current page.
- The first application will grant a free quota, allowing you to experience the Midjourney MCP service for free.

One Token can be used for all 11 MCP Servers provided by AceData Cloud, without needing to apply separately for Midjourney. The documentation and screenshots suggest displaying only a desensitized form, such as 3b78cc40dd3b43db806a4300...., and not posting the complete Token in public repositories, issues, screenshots, or chat logs.
Want to use Claude Desktop / Claude.ai web version for direct OAuth one-click authorization? Please see the Claude.ai / Desktop tutorial for Midjourney MCP.
¶ Configure OpenCode
OpenCode uses a single opencode.json file to describe all MCP Servers. The file can be placed in two locations; choose one based on the "scope" below. The field structure in both locations is identical, with the only difference being priority.
It is strongly recommended to first write the Token to an environment variable:
export ACEDATACLOUD_API_KEY="replace with your actual Token"
Then reference it in opencode.json using the {env:ACEDATACLOUD_API_KEY} placeholder to avoid writing the actual Token into the file.
¶ Global: Shared by All Projects
File location: ~/.config/opencode/opencode.json, suitable for "my own machine, configured once, usable by all projects."
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"midjourney": {
"type": "remote",
"url": "https://midjourney.mcp.acedata.cloud/mcp",
"enabled": true,
"oauth": false,
"headers": { "Authorization": "Bearer {env:ACEDATACLOUD_API_KEY}" }
}
}
}
⚠️
"oauth": falsecannot be omitted. AceData's MCP Server uses Bearer Token authentication and does not follow the OAuth process; OpenCode will automatically redirect 401 as an OAuth challenge, causingopencode mcp listto showSSE error: Non-200 status code (401). Explicitly declaring"oauth": falseallows OpenCode to call directly withAuthorization: Bearer ..., andopencode mcp debug midjourneywill also echoOAuth explicitly disabled, indicating it is effective.
¶ Project-Level: Effective Only for Current Project
File location: opencode.json in the current project root directory, which will override the global configuration. Suitable for team sharing, single repository customization, or temporarily enabling a specific MCP in a project.
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"midjourney": {
"type": "remote",
"url": "https://midjourney.mcp.acedata.cloud/mcp",
"enabled": true,
"oauth": false,
"headers": { "Authorization": "Bearer {env:ACEDATACLOUD_API_KEY}" }
}
}
}
If the project-level opencode.json will be committed to Git, please ensure to use the {env:ACEDATACLOUD_API_KEY} placeholder instead of the actual Token to avoid leakage.
💡 If the
.envin Shell is not explicitlyexported, you need to useset -a && source .env && set +ato pass the variables to the OpenCode process; otherwise,opencode debug configwill show"Authorization": "Bearer "(placeholder not resolved).
¶ Actual Running Results
Below is the desensitized output after actual execution in an isolated temporary directory using OpenCode 1.15.13. The command uses the actual AceData Cloud Token, and the Token in the output has been replaced with 357265014ad145fc8ab2...., and the temporary configuration has been deleted.
$ opencode --version
1.15.13
$ opencode mcp list
┌ MCP Servers
│
● ✓ midjourney connected
│ https://midjourney.mcp.acedata.cloud/mcp
│
└ 1 server(s)
Seeing ✓ midjourney connected indicates that the Midjourney MCP has been successfully integrated. If it shows ✗ or unauthorized, please check if ACEDATACLOUD_API_KEY is set, if the Token is copied completely, and if the Authorization prefix is Bearer (pay attention to case and spaces).
To debug the connection details of a specific MCP:
opencode mcp debug midjourney
After a successful handshake, OpenCode's INFO log will output service=mcp key=midjourney transport=StreamableHTTP connected and service=mcp key=midjourney toolCount=16 (tested with 16 tools), indicating that the Midjourney MCP is ready to be called by the model.
🤖 Model Selection Practical Advice: To truly allow the model to actively call the Midjourney MCP in OpenCode, please prioritize using OpenAI series models (such as
acedatacloud/gpt-5-mini,acedatacloud/gpt-5). When the Claude series models on AceData are exposed through the OpenAI compatible interface, tool calls often returnImproperly formed request(tested:acedatacloud/claude-haiku-4-5-20251001,acedatacloud/claude-sonnet-4-6reported this error when mounting multiple MCPs). Claude models can be used normally when only doing dialogue without calling tools.
¶ Typical Scenarios
After configuration is complete, you can directly call using natural language in the OpenCode session without switching to /mcp:
Generate an Image in One Sentence
Generate a cyberpunk-style city night scene with neon lights, wet streets, cinematic feel, 16:9
Maintain Consistent Style with Reference Image
Use this image as a style reference to create a similarly dark cyberpunk-style tech company homepage banner
Reverse Analyze Prompt
Analyze what Midjourney prompt might have been used for this image
¶ Tool List
The table below lists the main tools (The Midjourney MCP Server has exposed a total of 16 tools, which can be obtained through curl -X POST https://midjourney.mcp.acedata.cloud/mcp -H 'Authorization: Bearer <token>' -H 'Accept: application/json' -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' for a complete list):
| Tool | Description |
|---|---|
| midjourney_imagine | Text to image generation |
| midjourney_blend | Blend multiple images |
| midjourney_with_reference | Generate with reference image (style/character consistency) |
| midjourney_describe | AI describes image content |
| midjourney_edit | Image editing (local repainting, variations) |
| midjourney_generate_video | Image to video generation |
| midjourney_translate | Translate to English description |
