OpenCode Integration with Google Search MCP

📘 Overview: OpenCode MCP Overview →

You are troubleshooting an OOM issue with OpenCode on a remote server and see an unfamiliar kernel log. Previously, you could only copy the error message, disconnect from the terminal, switch to a local browser to search, and then switch back. After connecting the Serp MCP Server, OpenCode can search Google directly in the terminal, completing the entire chain of “view logs → search for information → modify code” without leaving the command line.

Google Search MCP is suitable for debugging production issues in OpenCode, conducting technical selection research, looking up official documentation, finding GitHub issues, and any scenario where “you need to search the web to continue working”.

Get an API Token

Before using the Google Search MCP Server, you need to prepare an Ace Data Cloud API Token. OpenCode and Claude Code share the same Token, and the acquisition process is the same:

  1. Open the Ace Data Cloud Console - Application List, obtain your API Token, and keep it for later use.
  2. If you have not logged in or registered yet, you will be automatically redirected to the login page; after logging in or registering, you will automatically return to the current page.
  3. Confirm that the key is allowed to access the required interfaces, and check the balance and quota in the console.

Get Ace Data Cloud API Key

An API Key for a general application can be reused within its authorization scope. It is recommended to display only a masked form in documentation and screenshots, such as YOUR_ACEDATACLOUD_API_KEY; do not paste the full Token into public repositories, Issues, screenshots, or chat history.

Want to use Claude Desktop / the Claude.ai web version for direct OAuth one-click authorization? See the Google Search MCP Claude.ai / Desktop Tutorial.

Configure OpenCode

First run opencode --version. For 2.x users, set ACEDATACLOUD_API_KEY in the terminal, then run the following commands.

opencode mcp add serp --global --url https://serp.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 two locations; choose one according to the “scope” below. The field structures at both locations are exactly the same; the only difference is 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, configure it once, and all projects can use it”.

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "serp": {
      "type": "remote",
      "url": "https://serp.mcp.acedata.cloud/mcp",
      "enabled": true,
      "oauth": false,
      "headers": { "Authorization": "Bearer {env:ACEDATACLOUD_API_KEY}" }
    }
  }
}

A Bearer API Key is used here. "oauth": false makes OpenCode send request headers according to this configuration.

Project-Level: Effective Only for the Current Project

File location: opencode.json in the current project root directory. For services with the same name, the definition in the project is used first. Suitable for team sharing, single-repository customization, or temporarily enabling an MCP only in a particular project.

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "serp": {
      "type": "remote",
      "url": "https://serp.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 a real Token to avoid leaks.

Please start OpenCode from a terminal where this environment variable has already been set and exported.

Verify the Connection

After configuration, run:

opencode mcp list

Seeing serp 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 continue to change; please select a model from the current directory that supports native tool calling.

Typical Scenarios

After configuration is complete, you can invoke it directly using natural language in an OpenCode session, without first switching to /mcp:

Debug Production Issues

Search how to solve nginx 502 bad gateway response header too large

Technical Selection Research

Search for a performance comparison of Python asynchronous ORMs in 2025, SQLAlchemy 2.0 async vs Tortoise ORM

Look Up Official Documentation

Search the official documentation for Kubernetes CronJob concurrencyPolicy, and the difference between Forbid and Replace

Tool List

The table below lists commonly used tools. For complete names, see the real-time tool list of the hosted service.

Tool Description
serp_google_search Google web search, supports specifying country, language, and time range
serp_google_images Google image search
serp_google_news Google news search
serp_google_videos Google video search
serp_google_maps / serp_google_places Map / local business search