Tutorial

How to Add Web Search to a Coding Agent

Learn how to give your coding agent (Claude Code, Cursor, OpenCode) live web search so it can look up docs, APIs, and errors in real time.

Coding agents like Claude Code, Cursor, and OpenCode are more effective when they can search the web for current documentation, API references, and error solutions. Without web search, they rely on training data that may be outdated for fast-moving libraries. This tutorial adds Scavio's search via MCP for IDE-based agents and via REST API for custom agents.

Prerequisites

  • A coding agent (Claude Code, Cursor, or custom)
  • A Scavio API key from scavio.dev

Walkthrough

Step 1: Configure MCP for Claude Code

Add Scavio's MCP server to Claude Code's project config.

JSON
// .claude/mcp.json (project-level config):
{
  "mcpServers": {
    "scavio": {
      "url": "https://mcp.scavio.dev/mcp",
      "headers": {
        "x-api-key": "your_scavio_api_key"
      }
    }
  }
}

Step 2: Configure MCP for Cursor

Add Scavio to Cursor's MCP configuration.

JSON
// .cursor/mcp.json:
{
  "mcpServers": {
    "scavio": {
      "url": "https://mcp.scavio.dev/mcp",
      "headers": {
        "x-api-key": "your_scavio_api_key"
      }
    }
  }
}

Step 3: For custom coding agents, add a search tool

If you are building a custom coding agent, add a search function as a tool.

Python
import requests, os

def web_search(query: str) -> str:
    """Search the web for documentation, API references, and error solutions."""
    resp = requests.post('https://api.scavio.dev/api/v1/search',
        headers={'x-api-key': os.environ['SCAVIO_API_KEY']},
        json={'platform': 'google', 'query': query}, timeout=10)
    results = resp.json().get('organic', [])[:5]
    return '\n'.join(f'{r["title"]}: {r["snippet"]} ({r["link"]})' for r in results)

Step 4: Test with common coding queries

Verify the search works for typical coding agent queries.

Python
# Test queries:
print(web_search('Next.js 15 app router migration guide'))
print(web_search('Python requests timeout error handling'))
print(web_search('React useEffect cleanup function'))

Python Example

Python
import requests, os
H = {'x-api-key': os.environ['SCAVIO_API_KEY']}

def search_docs(query):
    data = requests.post('https://api.scavio.dev/api/v1/search', headers=H,
        json={'platform': 'google', 'query': query}, timeout=10).json()
    return [(r['title'], r['link']) for r in data.get('organic', [])[:5]]

JavaScript Example

JavaScript
async function searchDocs(query) {
  const data = await fetch('https://api.scavio.dev/api/v1/search', {
    method: 'POST', headers: {'x-api-key': process.env.SCAVIO_API_KEY, 'Content-Type': 'application/json'},
    body: JSON.stringify({platform: 'google', query})
  }).then(r => r.json());
  return (data.organic || []).slice(0, 5).map(r => ({title: r.title, url: r.link}));
}

Expected Output

JSON
A coding agent with live web search for documentation, API references, and error solutions via MCP or REST API.

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.

A coding agent (Claude Code, Cursor, or custom). A Scavio API key from scavio.dev. 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

Learn how to give your coding agent (Claude Code, Cursor, OpenCode) live web search so it can look up docs, APIs, and errors in real time.