How to Use NanoBanana MCP in OpenCode for Multi-Image Editing

How to Use NanoBanana MCP in OpenCode for Multi-Image Editing

Multi-image editing becomes much more useful when it can stay inside the same terminal workflow where you are already writing docs, adjusting product copy, or preparing release assets.

What you can do

The NanoBanana MCP server is designed for image generation and image editing workflows inside OpenCode. The documented strengths are practical rather than abstract: product background replacement, virtual try-on, subject-consistent edits for people or objects, and editing one image with another image as a reference.

In an OpenCode session, that means you can ask for tasks such as:

  • placing a product image into a scene while keeping lighting consistent;
  • changing a model image to wear a referenced garment while preserving face and pose;
  • generating a small illustration for a 404 page or documentation page;
  • using several source images as references without leaving the terminal.

How it works

OpenCode reads MCP servers from an opencode.json file. Ace Data Cloud exposes NanoBanana as a remote MCP endpoint, so OpenCode connects to it over HTTPS and passes your Bearer token in the request headers. The important endpoint from the document is:

https://nanobanana.mcp.acedata.cloud/mcp

The server provides two main tools in the documentation:

  • nanobanana_generate_image for text-to-image generation.
  • nanobanana_edit_image for image editing, including multiple image inputs.

The implementation detail that trips people up is authentication. The config must include oauth: false, because this MCP server uses Bearer Token authentication rather than OpenCode's OAuth challenge flow.

Configure the token without leaking it

Start by putting your Ace Data Cloud API token into an environment variable. Do not paste the real token into a repository, issue, screenshot, or shared chat.

export ACEDATACLOUD_API_KEY="replace with your real token"

If you keep variables in a local .env file, make sure they are exported to the OpenCode process. The document notes this pattern:

set -a && source .env && set +a

Without exporting, OpenCode may resolve the header as Authorization: Bearer , which looks like an authentication problem even though the config file shape is correct.

Use a global OpenCode configuration

For a personal machine where you want NanoBanana available across projects, place the MCP config at ~/.config/opencode/opencode.json:

{
  "$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}" }
    }
  }
}

The field meanings are simple: type is remote, url points to the hosted MCP server, enabled turns the server on, oauth disables OAuth handling, and headers.Authorization injects your Bearer token from the environment.

Use a project-level configuration

If a single repository needs this workflow, put the same structure in opencode.json at the project root. The document states that project-level config overrides global config, which is useful for teams or repo-specific tool choices.

When committing a project-level file, keep the placeholder form:

"headers": { "Authorization": "Bearer {env:ACEDATACLOUD_API_KEY}" }

That keeps the config reviewable while leaving the secret on each developer's machine.

Verify the MCP connection

After saving the config, verify the handshake from the terminal:

opencode mcp list
opencode mcp debug nanobanana

A working setup should show nanobanana connected. If it fails, check three things in order: the environment variable is exported, oauth is explicitly false, and the authorization header includes the Bearer prefix.

Inspect the available tools directly

You can also ask the MCP endpoint for its current tool list with a JSON-RPC request. The document provides this request shape:

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"}'

This is a useful debugging step because model and tool schemas can change over time. Instead of hard-coding expectations in your workflow, inspect the current server response when something feels off.

A practical workflow

Once connected, keep the prompt concrete. For example, in OpenCode you might write:

Change this model image to wear this clothing image, keeping the face and pose unchanged.

Or for product work:

Put this product image into this scene image, keeping the lighting consistent.

The benefit is not only image editing; it is reducing context switching. You can prepare docs, inspect assets, call the MCP tool, and paste the resulting image URL back into your project notes or README from the same terminal session.

Closing notes

NanoBanana MCP is a good fit when you need reference-based image edits rather than a one-off generated picture. Start with a project-level opencode.json, confirm opencode mcp list shows the server as connected, and then move the config global only if you want it available everywhere.

Read the full source document here: OpenCode with Nano Banana MCP.

Comments

Popular posts from this blog

Artistic QR Code API Integration Guidance

How to Configure Claude Code with CC Switch and Ace Data Cloud

How to Build a Server-Side Image Editing Workflow with GPT-Image-2