Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.
TypeScript aeoai-agentai-searchanswer-engine-optimizationbrand-monitoringchatgptclaudecopilotdockergeminigeogoogle-ai-overviewsgrokmcpnextjsopen-sourceperplexityseosupabasetypescript
import { NextResponse } from 'next/server';
import { authenticateMcpRequest } from '@/lib/mcp-auth';
import { getSiteAuditFor } from '@/lib/mcp/data';
/**
* GET /api/mcp/site-audits/[id]
*
* Parallel REST surface for the `get_site_audit` MCP tool — same data-layer
* function, same ownership guarantee. Pure read; no quota consumed.
*/
export async function GET(req: Request, { params }: { params: Promise<{ id: string }> }) {
const auth = await authenticateMcpRequest(req);
if (auth instanceof NextResponse) return auth;
const { id } = await params;
if (!id) {
return NextResponse.json({ error: 'id is required' }, { status: 400 });
}
try {
const audit = await getSiteAuditFor(auth, id);
if (!audit) {
return NextResponse.json({ error: 'Audit not found' }, { status: 404 });
}
return NextResponse.json(audit);
} catch (err) {
const message = err instanceof Error ? err.message : 'Failed';
return NextResponse.json({ error: message }, { status: 500 });
}
}