Integrating NanoBanana MCP with OpenCode
📘 Overview: OpenCode MCP Overview →
NanoBanana is based on Gemini's image capabilities and is particularly strong at "using multiple image references while maintaining subject consistency"—you can reference a product photo and a model photo at the same time, and produce a composite image of "the model wearing the product." After connecting the NanoBanana MCP Server in OpenCode, you can complete this kind of multi-image editing task without writing complex prompts.
NanoBanana MCP is particularly suitable for e-commerce scenarios: changing product backgrounds, virtual try-ons, consistent editing of people / objects, and "using one reference image to modify another image."
¶ Get an API Token
Before using the NanoBanana MCP Server, you need to prepare an Ace Data Cloud API Token. OpenCode and Claude Code use the same set of Tokens, and the process for obtaining one is the same:
- Open the Ace Data Cloud Console - Application List and obtain your API Token for later use.
- If you have not 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 allowed to access the required APIs, and check your balance and limits in the console.

A general-purpose application's API Key can be reused within its authorized scope. In documentation and screenshots, it is recommended to show only a redacted form, such as YOUR_ACEDATACLOUD_API_KEY; do not paste the full Token into public repositories, Issues, screenshots, or chat logs.
Want to use Claude Desktop / the Claude.ai web version for one-click OAuth authorization directly? See the NanoBanana MCP Claude.ai / Desktop tutorial.
¶ Configure OpenCode
First, run opencode --version. OpenCode 2.x users should set ACEDATACLOUD_API_KEY in the terminal, then run the following commands.
opencode mcp add nanobanana --global --url https://nanobanana.mcp.acedata.cloud/mcp --header 'Authorization=Bearer {env:ACEDATACLOUD_API_KEY}'
opencode reload
opencode mcp list
¶ OpenCode 1.x Configuration
OpenCode uses an opencode.json file to describe all MCP Servers. The file can be placed in either of two locations; choose one according to the "scope" below. The field structures in both locations are exactly the same; the only difference is priority.
It is strongly recommended to put the Token in an environment variable first:
export ACEDATACLOUD_API_KEY="替换为你的真实 Token"
Then reference it in opencode.json using the {env:ACEDATACLOUD_API_KEY} placeholder to avoid writing the real Token into the file.
¶ Global: Shared by All Projects
File location: ~/.config/opencode/opencode.json, suitable for "my own machine, configure once, use in all projects."
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"nanobanana": {
"type": "remote",
"url": "https://nanobanana.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 the request header according to this configuration.
¶ Project-Level: Applies Only to the Current Project
File location: opencode.json in the current project's root directory. For services with the same name, the definition in the project takes priority. Suitable for team sharing, single-repository customization, or temporarily enabling an MCP only in a particular project.
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"nanobanana": {
"type": "remote",
"url": "https://nanobanana.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 launch OpenCode from a terminal where the environment variable has been set and exported.
¶ Verify the Connection
After configuration, run:
opencode mcp list
Seeing nanobanana connected means 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 change continually, so please select a model that supports native tool calling from the current catalog.
¶ Typical Scenarios
Once configuration is complete, you can call it directly using natural language in an OpenCode session, without first switching to /mcp:
Multi-Image Composition
把这张商品图(链接 A)放到这张场景图(链接 B)里,保持光影一致
Changing Clothes While Maintaining Person Consistency
把这张模特图换成穿这件衣服(链接 xxx),脸和姿势不变
Generating Page Illustrations
生成一只小恐龙蹲在地面裂缝旁边往下看的插画,用作 404 页面
¶ Tool List
The table below lists commonly used tools; for full names, see the hosted service's live tool list.
| Tool | Description |
|---|---|
| nanobanana_generate_image | Generate images from text |
| nanobanana_edit_image | Edit images (supports multiple image inputs) |
