ScavioScavio
ProductPricingDocs
Sign InGet Started
  1. Home
  2. Tutorials
  3. How to Add Search MCP to OpenCode Harness
Tutorial

How to Add Search MCP to OpenCode Harness

Configure Scavio search MCP for OpenCode coding harness. Give OpenCode agents live web search for docs and API lookups.

Get Free API KeyAPI Docs

OpenCode harness runs coding agents but they lack web access for looking up current documentation and API references. Adding a search MCP server gives OpenCode agents the ability to verify facts, check package versions, and find documentation before generating code. Setup takes 3 minutes.

Prerequisites

  • OpenCode harness installed
  • Node.js 18+ or Python 3.8+
  • A Scavio API key from scavio.dev
  • Basic MCP configuration knowledge

Walkthrough

Step 1: Add MCP server to OpenCode config

Configure the search MCP server in OpenCode settings.

Python
import json, os

# OpenCode MCP configuration
opencode_mcp = {
    'mcpServers': {
        'scavio-search': {
            'command': 'npx',
            'args': ['-y', 'scavio-search-mcp'],
            'env': {
                'SCAVIO_API_KEY': os.environ.get('SCAVIO_API_KEY', 'your-key-here')
            }
        }
    }
}

# Save to OpenCode config
config_path = os.path.expanduser('~/.opencode/mcp.json')
print(f'OpenCode MCP config: {config_path}')
print(json.dumps(opencode_mcp, indent=2))
print(f'\nThis gives OpenCode agents these tools:')
print(f'  - web_search: Search Google, Reddit, Amazon, YouTube')
print(f'  - extract: Read content from any URL')
print(f'  - tiktok_search: Search TikTok videos and profiles')

Step 2: Test search tool from OpenCode

Verify the MCP connection works by running test searches.

Python
import os, requests

API_KEY = os.environ['SCAVIO_API_KEY']
SH = {'x-api-key': API_KEY, 'Content-Type': 'application/json'}

def test_opencode_search(query):
    """Test the search tool as OpenCode would call it."""
    data = requests.post('https://api.scavio.dev/api/v1/search',
        headers=SH, json={'query': query, 'country_code': 'us', 'num_results': 5}).json()
    results = data.get('organic_results', [])
    return [{'title': r.get('title', ''), 'snippet': r.get('snippet', ''),
             'link': r.get('link', '')} for r in results[:5]]

# Coding-relevant test queries
tests = [
    ('Package lookup', 'pydantic v2 latest version'),
    ('API docs', 'fastapi websocket documentation'),
    ('Error fix', 'python asyncio RuntimeError event loop'),
    ('Best practice', 'python project structure 2026'),
]

for label, query in tests:
    results = test_opencode_search(query)
    print(f'  [{label}] "{query}" -> {len(results)} results')
    if results:
        print(f'    Top: {results[0]["title"][:50]}')
print(f'\nAll tests passed. Cost: ${len(tests) * 0.005:.3f}')

Step 3: Optimize search for coding workflows

Configure search patterns that work best for code-related queries.

Python
def coding_search(query, search_type='docs'):
    """Optimized search for different coding needs."""
    suffixes = {
        'docs': 'documentation official',
        'error': 'fix solution stackoverflow',
        'version': 'latest version release notes',
        'example': 'code example tutorial',
    }
    enhanced_query = f'{query} {suffixes.get(search_type, "")}'
    data = requests.post('https://api.scavio.dev/api/v1/search',
        headers=SH, json={'query': enhanced_query, 'country_code': 'us', 'num_results': 5}).json()
    results = data.get('organic_results', [])
    return [{'title': r.get('title', ''), 'url': r.get('link', ''),
             'snippet': r.get('snippet', '')} for r in results[:5]]

print('=== Coding Search Patterns ===')
for stype in ['docs', 'error', 'version', 'example']:
    results = coding_search('fastapi', stype)
    print(f'\n  [{stype}] fastapi: {len(results)} results')
    if results:
        print(f'    {results[0]["title"][:60]}')
print(f'\nCost: $0.020')

Python Example

Python
import os, requests
SH = {'x-api-key': os.environ['SCAVIO_API_KEY'], 'Content-Type': 'application/json'}

def opencode_search(query):
    data = requests.post('https://api.scavio.dev/api/v1/search',
        headers=SH, json={'query': f'{query} documentation', 'country_code': 'us'}).json()
    for r in data.get('organic_results', [])[:3]:
        print(f'  {r["title"]}: {r.get("link", "")}')

opencode_search('pydantic v2')
print('Cost: $0.005')

JavaScript Example

JavaScript
const SH = { 'x-api-key': process.env.SCAVIO_API_KEY, 'Content-Type': 'application/json' };
const data = await fetch('https://api.scavio.dev/api/v1/search', {
  method: 'POST', headers: SH,
  body: JSON.stringify({ query: 'pydantic v2 documentation', country_code: 'us' })
}).then(r => r.json());
(data.organic_results || []).slice(0, 3).forEach(r => console.log(`${r.title}: ${r.link}`));

Expected Output

JSON
OpenCode MCP config: ~/.opencode/mcp.json

  [Package lookup] "pydantic v2 latest version" -> 5 results
    Top: Pydantic V2 Release Notes
  [API docs] "fastapi websocket documentation" -> 5 results
    Top: WebSockets - FastAPI Documentation
  [Error fix] "python asyncio RuntimeError event loop" -> 5 results
  [Best practice] "python project structure 2026" -> 5 results

All tests passed. Cost: $0.020

Related Tutorials

  • How to Add Web Search to opencode CLI
  • How to Configure MCP Search in opencode.json
  • How to Add Web Search to OpenCode Multi-Expert

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 harness installed. Node.js 18+ or Python 3.8+. A Scavio API key from scavio.dev. Basic MCP configuration knowledge. A Scavio API key gives you 50 free credits on signup.

Yes. The free tier includes 50 credits on signup, 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.

Related Resources

Use Case

IDE MCP Search

Read more
Best Of

Best Web Search API for opencode CLI in 2026

Read more
Best Of

Best MCP Search Tools for Claude Desktop in 2026

Read more
Use Case

opencode MCP Web Search Integration

Read more
Glossary

MCP as Default Web Search

Read more
Solution

Add Web Search to Any MCP Client

Read more

Start Building

Configure Scavio search MCP for OpenCode coding harness. Give OpenCode agents live web search for docs and API lookups.

Get Free API KeyRead the Docs
ScavioScavio

Real-time search API for AI agents. Search every platform, not just Google.

Product

  • Features
  • Pricing
  • Dashboard
  • Affiliates

Developers

  • Documentation
  • API Reference
  • Quickstart
  • MCP Integration
  • Python SDK

Alternatives

  • Tavily Alternative
  • SerpAPI Alternative
  • Firecrawl Alternative
  • Exa Alternative

Tools

  • JSON Formatter
  • cURL to Code
  • Token Counter
  • All Tools

© 2026 Scavio. All rights reserved.

Featured on TAAFT
Terms of ServicePrivacy Policy