AI agents hallucinate outdated APIs, wrong versions, and fabricated data because their training data is months old. Search grounding gives agents live web access to verify facts before responding. Cost: 3-5 searches per task at $0.015-0.025.
Prerequisites
- Claude Code or Python agent framework
- Scavio API key
- Basic understanding of MCP or tool calling
Walkthrough
Step 1: Configure MCP search server
Add Scavio MCP to your .mcp.json for native Claude Code integration.
Step 2: Define search tool for agents
Create a search tool function that the agent can call when uncertain about facts.
Step 3: Add grounding logic
Instruct the agent to search before recommending packages, APIs, or version numbers.
Step 4: Test with known-stale queries
Ask about recent releases to verify the agent searches instead of guessing.
Python Example
import requests, os
H = {'x-api-key': os.environ['SCAVIO_API_KEY'], 'Content-Type': 'application/json'}
def search_ground(query):
resp = requests.post('https://api.scavio.dev/api/v1/search',
headers=H, json={'query': query, 'country_code': 'us', 'num_results': 5})
data = resp.json()
return [{'title': r['title'], 'snippet': r.get('snippet', '')} for r in data.get('organic_results', [])[:5]]
# Agent uses this before recommending
results = search_ground('next.js latest version 2026')
for r in results:
print(f"{r['title']}: {r['snippet'][:100]}")JavaScript Example
async function searchGround(query) {
const resp = 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({query, country_code: 'us', num_results: 5})
});
const data = await resp.json();
return data.organic_results?.slice(0,5).map(r => ({title: r.title, snippet: r.snippet}));
}
const results = await searchGround('next.js latest version 2026');
results.forEach(r => console.log(r.title));Expected Output
Next.js 16.1 Release Notes: Next.js 16.1 introduces...
Next.js Blog: Announcing Next.js 16...
...