You can build an SEO audit agent in Claude Code by giving it the Scavio MCP tool and a structured prompt. The agent searches target keywords, checks AI Overview presence, identifies ranking gaps, and generates a report without manual data collection.
Prerequisites
- Claude Code installed
- Scavio MCP configured in .mcp.json
- Target keyword list
Walkthrough
Step 1: Configure Scavio MCP in Claude Code
Add the Scavio MCP server to your project .mcp.json if not already done.
{
"mcpServers": {
"scavio": {
"command": "npx",
"args": ["-y", "@scavio/mcp-server"],
"env": { "SCAVIO_API_KEY": "your-scavio-api-key" }
}
}
}Step 2: Create the audit prompt file
Save this as seo-audit.md in your project. Open Claude Code and paste it into the chat.
# SEO Audit Task
Audit the following site for SEO performance: [YOUR DOMAIN]
For each keyword below, use the scavio search tool to:
1. Find the site's position in organic results (1-10 = page 1, 11-20 = page 2, not found = not ranking)
2. Check if an AI Overview is present (include_ai_overview: true)
3. Check if the site appears in the AI Overview sources
Keywords:
- [keyword 1]
- [keyword 2]
- [keyword 3]
Output a markdown table with columns: Keyword | Position | AI Overview | AIO Citation
Then write a 5-bullet action plan based on the findings.Step 3: Run the audit and parse results
Claude Code will call Scavio for each keyword and compile the results. For automated runs, use the Python script below.
import requests
from datetime import date
API_KEY = "your-scavio-api-key"
YOUR_DOMAIN = "yoursite.com"
def audit_keyword(keyword: str) -> dict:
r = requests.post(
"https://api.scavio.dev/api/v1/search",
json={"query": keyword, "include_ai_overview": True, "num_results": 20},
headers={"x-api-key": API_KEY},
timeout=20
)
data = r.json()
results = data.get("organic_results", [])
position = next(
(i + 1 for i, r in enumerate(results) if YOUR_DOMAIN in r.get("link", "")),
None
)
ao = data.get("ai_overview")
aio_cited = False
if ao:
aio_cited = any(YOUR_DOMAIN in s.get("link", "") for s in ao.get("sources", []))
return {
"keyword": keyword,
"position": position or "not ranking",
"ai_overview": bool(ao),
"aio_citation": aio_cited
}Step 4: Generate the audit report
Run audits for all keywords and print a markdown table.
KEYWORDS = [
"best project management software",
"project tracker for teams",
"asana alternative",
"free task management tool"
]
print(f"# SEO Audit - {YOUR_DOMAIN} - {date.today()}\n")
print("| Keyword | Position | AI Overview | AIO Citation |")
print("|---------|----------|-------------|--------------|")
for kw in KEYWORDS:
result = audit_keyword(kw)
pos = str(result['position'])
aio = 'yes' if result['ai_overview'] else 'no'
cited = 'yes' if result['aio_citation'] else 'no'
print(f"| {kw} | {pos} | {aio} | {cited} |")Python Example
import requests
from datetime import date
API_KEY = "your-scavio-api-key"
YOUR_DOMAIN = "yoursite.com"
KEYWORDS = [
"best project management software",
"project tracker for teams",
"asana alternative 2026",
"free task management tool",
"kanban board online"
]
def audit_keyword(keyword: str) -> dict:
r = requests.post(
"https://api.scavio.dev/api/v1/search",
json={"query": keyword, "include_ai_overview": True, "num_results": 20},
headers={"x-api-key": API_KEY},
timeout=20
)
r.raise_for_status()
data = r.json()
results = data.get("organic_results", [])
position = next((i + 1 for i, res in enumerate(results) if YOUR_DOMAIN in res.get("link", "")), None)
ao = data.get("ai_overview")
aio_cited = bool(ao and any(YOUR_DOMAIN in s.get("link", "") for s in ao.get("sources", [])))
return {"keyword": keyword, "position": position, "ai_overview": bool(ao), "aio_citation": aio_cited}
def generate_report(keywords: list, domain: str) -> str:
rows = [audit_keyword(kw) for kw in keywords]
lines = [f"# SEO Audit: {domain} — {date.today()}\n",
"| Keyword | Position | AI Overview | AIO Citation |",
"|---------|----------|-------------|--------------|"]
not_ranking = [r for r in rows if not r["position"]]
p2 = [r for r in rows if r["position"] and r["position"] > 10]
cited = [r for r in rows if r["aio_citation"]]
for row in rows:
pos = str(row["position"]) if row["position"] else "not ranking"
lines.append(f"| {row['keyword']} | {pos} | {'yes' if row['ai_overview'] else 'no'} | {'yes' if row['aio_citation'] else 'no'} |")
lines.append("\n## Action Plan")
if not_ranking:
lines.append(f"- Create or optimize pages for: {', '.join(r['keyword'] for r in not_ranking[:3])}")
if p2:
lines.append(f"- Build links to pages targeting: {', '.join(r['keyword'] for r in p2[:3])}")
if not cited:
lines.append("- No AI Overview citations detected. Add FAQ schema and expand definition sections.")
if cited:
lines.append(f"- Maintain AIO citations for: {', '.join(r['keyword'] for r in cited)}")
return "\n".join(lines)
if __name__ == "__main__":
print(generate_report(KEYWORDS, YOUR_DOMAIN))JavaScript Example
const API_KEY = 'your-scavio-api-key';
const YOUR_DOMAIN = 'yoursite.com';
async function auditKeyword(keyword) {
const res = await fetch('https://api.scavio.dev/api/v1/search', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'x-api-key': API_KEY },
body: JSON.stringify({ query: keyword, include_ai_overview: true, num_results: 20 })
});
const data = await res.json();
const results = data.organic_results ?? [];
const position = results.findIndex(r => r.link?.includes(YOUR_DOMAIN)) + 1 || null;
const ao = data.ai_overview;
const aioCited = ao ? (ao.sources ?? []).some(s => s.link?.includes(YOUR_DOMAIN)) : false;
return { keyword, position, aiOverview: !!ao, aioCited };
}
const keywords = ['best project management software', 'asana alternative 2026'];
const rows = await Promise.all(keywords.map(auditKeyword));
console.log('| Keyword | Position | AI Overview | AIO Citation |');
for (const row of rows) {
console.log(`| ${row.keyword} | ${row.position ?? 'not ranking'} | ${row.aiOverview ? 'yes' : 'no'} | ${row.aioCited ? 'yes' : 'no'} |`);
}Expected Output
# SEO Audit: yoursite.com - 2026-05-22
| Keyword | Position | AI Overview | AIO Citation |
|---------|----------|-------------|-------------- |
| best project management software | 7 | yes | no |
| project tracker for teams | not ranking | no | no |
| asana alternative 2026 | 14 | yes | yes |
| free task management tool | 3 | yes | no |
| kanban board online | not ranking | yes | no |
## Action Plan
- Create or optimize pages for: project tracker for teams, kanban board online
- Build links to pages targeting: asana alternative 2026
- No AI Overview citations for most keywords. Add FAQ schema and expand definition sections.