OpenCode Integration with NanoBanana MCP

📘 OverviewOpenCode MCP Overview →

NanoBanana, based on Gemini's image capabilities, has a particular advantage in "multi-image reference, maintaining subject consistency"—it can reference product photos while also referencing model photos, ultimately producing a composite image of "the model wearing the product." After connecting to the NanoBanana MCP Server in OpenCode, you can complete such multi-image editing tasks without writing complex prompts.

NanoBanana MCP is especially suitable for e-commerce scenarios: changing backgrounds for products, virtual try-ons, consistency editing for people/objects, and "modifying one image using a reference image."

Obtain API Token

Before using the NanoBanana 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:

  1. Open the Ace Data Cloud Console - Application List to obtain your API Token for backup.
  2. If you are 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.
  3. The first application will come with a free quota, allowing you to experience the NanoBanana MCP service for free.

Obtain Ace Data Cloud API Key

One token can be used for all MCP Servers provided by Ace Data Cloud, and there is no need to apply separately for NanoBanana. The documentation and screenshots suggest displaying only the masked form, such as YOUR_ACEDATACLOUD_API_KEY, and do not paste the complete token into public repositories, issues, screenshots, or chat records.

Want to use Claude Desktop / Claude.ai web version for direct OAuth one-click authorization? Please refer to the Claude.ai / Desktop tutorial for NanoBanana MCP.

Configure OpenCode

OpenCode describes all MCP Servers in a single opencode.json file, which can be placed in two locations; choose one according to the "scope" below. The field structure in both locations is exactly the same, 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 real 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, configured once, usable by 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}" }
    }
  }
}

⚠️ "oauth": false cannot be omitted. AceData's MCP Server uses Bearer Token authentication and does not go through the OAuth process; OpenCode will automatically redirect 401 as an OAuth challenge, resulting in opencode mcp list showing SSE error: Non-200 status code (401). Explicitly declaring "oauth": false allows OpenCode to call directly with Authorization: Bearer ..., and opencode mcp debug nanobanana will also echo OAuth 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": {
    "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, please ensure to use the {env:ACEDATACLOUD_API_KEY} placeholder instead of the real token to avoid leakage.

💡 If the .env in Shell is not explicitly exported, you need to use set -a && source .env && set +a to pass the variables to the OpenCode process; otherwise, opencode debug config will show "Authorization": "Bearer " (placeholder not resolved).

Verify Connection

After configuration, run:

opencode mcp list
opencode mcp debug nanobanana

Seeing nanobanana connected indicates a successful handshake. If it fails, check whether ACEDATACLOUD_API_KEY has been exported, whether oauth is set to false, and whether Authorization includes the Bearer prefix. The model and tool schema will continue to change, so please select models that support native tool calls from the current directory.

Typical Scenarios

After configuration, you can directly call using natural language in the OpenCode session without switching to /mcp:

Multi-Image Composition

Put this product image (link A) into this scene image (link B), keeping the lighting consistent.

Changing Outfits While Maintaining Character Consistency

Change this model image to wear this piece of clothing (link xxx), keeping the face and pose unchanged.

Generating Page Illustrations

Generate an illustration of a small dinosaur squatting next to a crack in the ground looking down, to be used as a 404 page.

Tool List

The table below lists the main tools; you can obtain the current complete list by using curl -X POST https://nanobanana.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"}':

Tool Description
nanobanana_generate_image Text to image generation
nanobanana_edit_image Image editing (supports multiple image inputs)