Tutorial

How to Add Web Search to opencode CLI

Give opencode CLI live multi-surface web search in one config line using the Scavio MCP endpoint.

opencode CLI and similar terminal coding agents discover MCP servers from config. Adding Scavio gives the agent live Google SERP, Reddit, YouTube, and doc search in one tool class. This tutorial wires it up in under 10 minutes.

Prerequisites

  • opencode CLI installed
  • A Scavio API key
  • Node.js 20+ (for mcp-remote bridge)

Walkthrough

Step 1: Open the opencode MCP config

opencode reads MCP servers from ~/.opencode/mcp.json.

Bash
mkdir -p ~/.opencode && touch ~/.opencode/mcp.json

Step 2: Register the Scavio MCP

Use mcp-remote to bridge HTTP SSE into a CLI process.

JSON
{
  "mcpServers": {
    "scavio": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://mcp.scavio.dev/mcp"],
      "env": { "SCAVIO_API_KEY": "${SCAVIO_API_KEY}" }
    }
  }
}

Step 3: Export the API key

Load from your shell rc so the CLI inherits it.

Bash
echo 'export SCAVIO_API_KEY=sk_live_...' >> ~/.zshrc && source ~/.zshrc

Step 4: Verify the tools are visible

Start opencode and list tools.

Bash
opencode
> /tools
# Expect scavio_search, scavio_reddit, scavio_youtube

Step 5: Test a live query

Ask for something that requires fresh data.

Bash
> what does the latest r/opencodeCLI thread on web search say?

Python Example

Python
# opencode CLI is a CLI-first tool; no Python setup needed.
# To test the MCP endpoint directly:
import requests, os
API_KEY = os.environ['SCAVIO_API_KEY']
r = requests.post('https://api.scavio.dev/api/v1/search',
    headers={'x-api-key': API_KEY},
    json={'query': 'opencode CLI web search'})
print(r.json().get('organic_results', [])[:3])

JavaScript Example

JavaScript
// opencode discovers tools from mcp.json; no JS code required.
// Direct API call for parity:
const API_KEY = process.env.SCAVIO_API_KEY;
const r = await fetch('https://api.scavio.dev/api/v1/search', {
  method: 'POST',
  headers: { 'x-api-key': API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({ query: 'opencode CLI web search' })
});
console.log(((await r.json()).organic_results || []).slice(0, 3));

Expected Output

JSON
opencode CLI exposes scavio_* tools in /tools. The agent calls them automatically when the user question needs live data.

Related Tutorials

Frequently Asked Questions

Most developers complete this tutorial in 15 to 30 minutes. You will need a Scavio API key (free tier works) and a working Python or JavaScript environment.

opencode CLI installed. A Scavio API key. Node.js 20+ (for mcp-remote bridge). A Scavio API key gives you 500 free credits per month.

Yes. The free tier includes 500 credits per month, which is more than enough to complete this tutorial and prototype a working solution.

Scavio has a native LangChain package (langchain-scavio), an MCP server, and a plain REST API that works with any HTTP client. This tutorial uses the raw REST API, but you can adapt to your framework of choice.

Start Building

Give opencode CLI live multi-surface web search in one config line using the Scavio MCP endpoint.