OpenCode Integration with Flux MCP
📘 Overview: OpenCode MCP Overview →
Flux supports photorealistic image generation and Kontext image editing. After integrating the Flux MCP Server into OpenCode, you can generate or edit images based on the current conversation context.
Flux MCP is suitable for creating product hero images, photorealistic portraits, commercial advertising assets, and using the Kontext model to “edit existing images based on text descriptions”—such as changing backgrounds, styles, or text.
¶ Obtain an API Token
Before using the Flux MCP Server, you need to prepare an Ace Data Cloud API Token. OpenCode and Claude Code share the same set of Tokens, and the acquisition process is the same:
- Open the Ace Data Cloud Console - Application List, obtain your API Token, and keep it for later use.
- If you are not yet logged in or registered, you will be automatically redirected to the login page; after logging in or registering, you will automatically return to the current page.
- Confirm that the key is permitted to access the required APIs, and check your balance and limits in the console.

The API Key for a general application can be reused within its authorization scope. Documentation and screenshots are recommended to show only a masked form, such as YOUR_ACEDATACLOUD_API_KEY; do not paste the complete Token into public repositories, Issues, screenshots, or chat logs.
Want to directly authorize with one-click OAuth using Claude Desktop / the Claude.ai web version? See the Flux MCP Claude.ai / Desktop Tutorial.
¶ Configure OpenCode
First run opencode --version. For 2.x users, after setting ACEDATACLOUD_API_KEY in the terminal, execute the following commands.
opencode mcp add flux --global --url https://flux.mcp.acedata.cloud/mcp --header 'Authorization=Bearer {env:ACEDATACLOUD_API_KEY}'
opencode reload
opencode mcp list
¶ OpenCode 1.x Configuration
OpenCode uses one opencode.json file to describe all MCP Servers. The file can be placed in two locations; choose one according to the “scope” below. The field structure is exactly the same in both locations; the only difference is priority.
It is strongly recommended to write the Token into an environment variable first:
export ACEDATACLOUD_API_KEY="replace with your real Token"
Then use the {env:ACEDATACLOUD_API_KEY} placeholder in opencode.json to reference it, avoiding writing the real Token into the file.
¶ Global: Shared Across All Projects
File location: ~/.config/opencode/opencode.json, suitable for “my own machine, configure it once, and use it in all projects”.
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"flux": {
"type": "remote",
"url": "https://flux.mcp.acedata.cloud/mcp",
"enabled": true,
"oauth": false,
"headers": { "Authorization": "Bearer {env:ACEDATACLOUD_API_KEY}" }
}
}
}
A Bearer API Key is used here.
"oauth": falsemakes OpenCode send request headers according to this configuration.
¶ Project Level: Effective Only for the Current Project
File location: opencode.json in the root directory of the current project. For services with the same name, the definition in the project takes priority. Suitable for team sharing, single-repository customization, or temporarily enabling a certain MCP only in a specific project.
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"flux": {
"type": "remote",
"url": "https://flux.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, make sure to use the {env:ACEDATACLOUD_API_KEY} placeholder instead of the real Token to avoid leaks.
Please start OpenCode from a terminal where this environment variable has been set and exported.
¶ Verify the Connection
After configuration, run:
opencode mcp list
Seeing flux connected indicates that the handshake was successful. If it fails, check whether ACEDATACLOUD_API_KEY has been exported, the hosted address, and whether Authorization includes the Bearer prefix. Models and tool Schemas continue to change; please select a model from the current directory that supports native tool calling.
¶ Typical Scenarios
After the configuration is complete, you can directly invoke it using natural language in an OpenCode session, without first switching to /mcp:
Quick Image Generation
Use Flux to generate a cyberpunk-style city night scene, with neon lights, a rainy night, and wet streets
Edit an Existing Image with Kontext
Change this image (link xxx) into a watercolor painting style
Generate a Product Hero Image
Generate a 1024x1024 product hero image: black metallic-textured headphones floating against a white background
¶ Tool List
The table below lists commonly used tools. For complete names, see the real-time tool list of the hosted service.
| Tool | Description |
|---|---|
| flux_generate_image | Text-to-image generation (Flux pro / dev / ultra) |
| flux_edit_image | Edit existing images according to prompts (Flux Kontext pro / max) |
