OpenCode Integration with NanoBanana MCP

📘 OverviewOpenCode MCP Overview →

NanoBanana, based on Gemini's image capabilities, has a particular advantage in "multi-image reference and 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 grant a free quota, allowing you to experience the NanoBanana MCP service for free.

One token can be used for all 11 MCP Servers provided by AceData Cloud, without needing to apply separately for NanoBanana. The documentation and screenshots suggest displaying only a masked form, such as 3b78cc40dd3b43db806a4300...., and do not paste the full token into 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 NanoBanana MCP.

Configure OpenCode

OpenCode describes all MCP Servers in a single opencode.json file, which 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": {
    "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's 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 actual 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).

Actual Running Results

Below is the masked output after executing in an isolated temporary directory in 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
│
●  ✓ nanobanana connected
│      https://nanobanana.mcp.acedata.cloud/mcp
│
└  1 server(s)

Seeing ✓ nanobanana connected indicates that the NanoBanana MCP has been successfully integrated. If it shows or unauthorized, please check whether ACEDATACLOUD_API_KEY is set, whether the token is copied completely, and whether the Authorization prefix is Bearer (pay attention to case and spaces).

To debug the connection details of a specific MCP:

opencode mcp debug nanobanana

After a successful handshake, OpenCode's INFO log will output service=mcp key=nanobanana transport=StreamableHTTP connected and service=mcp key=nanobanana toolCount=4 (tested with 4 tools), indicating that the NanoBanana MCP is ready to be called by the model.

🤖 Model Selection Testing Suggestions: To truly allow the model to actively call the NanoBanana 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 return Improperly formed request (tested: acedatacloud/claude-haiku-4-5-20251001, acedatacloud/claude-sonnet-4-6 reported 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 in 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 for a 404 page.

Tool List

The table below lists the main tools (NanoBanana MCP Server has exposed a total of 4 tools, which can be obtained through 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"}' for a complete list):

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