OpenCode · opencode.json · type: remote

Image generation in OpenCode: MCP server setup

OpenCode nests servers under mcp, not mcpServers, and names the type "remote" rather than a transport — add the entry to opencode.json with url, headers and enabled. OpenCode is terminal-native and configuration-first, so the fastest route in is the config file rather than a wizard. It is also the client whose vocabulary diverges most from everyone else’s.

By the imagemcpserver.com teamPublished OpenCode docs checked September 2026

Add the server

Where the config lives
~/.config/opencode/opencode.json (global) · opencode.json (project)
The key it nests under
mcp
  1. 1

    Create an API key. Create a key in the imagemcpserver dashboard.

  2. 2

    Open opencode.json. Edit ~/.config/opencode/opencode.json, or an opencode.json in the project root.

  3. 3

    Add the entry under mcp. Use the mcp key, "type": "remote", and pass the key as a header.

  4. 4

    Restart OpenCode. Start a new session and ask it to list its tools to confirm the eleven image tools loaded.

opencode · recommendeduse this
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "imagemcp": {
      "type": "remote",
      "url": "https://mcp.imagemcpserver.com/mcp",
      "enabled": true,
      "headers": { "x-api-key": "sk-img-gen-…" }
    }
  }
}
Bearer token instead of x-api-key
// This server reads the key from an Authorization
// bearer token as well, if that fits your setup better.
{
  "mcp": {
    "imagemcp": {
      "type": "remote",
      "url": "https://mcp.imagemcpserver.com/mcp",
      "enabled": true,
      "headers": { "Authorization": "Bearer sk-img-gen-…" }
    }
  }
}

Two renames in one block

OpenCode calls the container mcp rather than mcpServers, and it describes the connection as "remote" rather than naming a transport like streamable-http or http. Neither is wrong, but neither matches the config you will have copied from anywhere else, and both fail quietly.

The endpoint and the key are identical in every client. The wrapper around them is not, and that wrapper is where almost every “correct” config that does nothing goes wrong. Checked September 2026 against OpenCode’s own documentation — see the sources below.

Three ways to send the key

The server resolves your API key from any of these, checked in this order. That matters when a client only gives you a URL field and no way to set a header — you are not stuck, and you do not need a bridge process.

Query parameter

?apikey=sk-img-gen-…

Checked first. The fallback for a client whose config is a bare URL field.

x-api-key header

x-api-key: sk-img-gen-…

The documented default, and what every client below uses unless noted.

Authorization header

Authorization: Bearer sk-img-gen-…

Accepted as a bearer token, which is what a client with only a token field will send.

A key in a query string ends up in shell history, process listings and any log the client keeps, so prefer a header where the client allows one. Where it does not, treat the whole URL as the secret and rotate it as freely as you would a password.

What each tool costs

Wherever OpenCode lets you approve tools individually, the useful line to draw is not between image tools and other tools — it is between calls with a fixed price and calls that route to a model.

get_user_infolist_models

free

Safe to auto-approve wherever the client supports it. These are how the agent finds out what it can afford before it spends anything.

compress_imageconvert_format

1 credit

Deterministic and cheap. Auto-approving these makes an optimisation pass over a whole folder painless.

remove_backgroundtext_to_svgupscale_image

5–15 credits

Fixed prices, no model routing. Auto-approve once you trust the workflow.

generate_imageedit_imagegenerate_transparent_imagemulticall

model-priced

These route to an image model and are the ones that can run up a bill in a loop. Keep approval on.

OpenCode questions

How do I add an MCP server to OpenCode?

Add an entry to the mcp object in opencode.json — globally at ~/.config/opencode/opencode.json, or per project in a local opencode.json. There is no separate command to run.

Why is my mcpServers block ignored?

Because OpenCode does not use that key. It reads mcp. A block copied from Cursor, Cline or Claude Desktop will parse as valid JSON and do nothing. Checked September 2026.

What does "type": "remote" mean here?

It is how OpenCode distinguishes a hosted server from a local one it spawns. It is not a transport name — there is no streamable-http or http value to choose between.

Does OpenCode handle OAuth for remote servers?

It will prompt for OAuth on servers that require it. This server authenticates by header instead, so supplying x-api-key means you are never prompted.

Can I disable the server without deleting the block?

Yes — set "enabled": false. Useful for keeping the config around while working on something that has no business generating images.