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 { z } from 'zod';
import { authenticateMcpRequest } from '@/lib/mcp-auth';
import { demoBrandRefusal } from '@/lib/mcp/demo-gate';
import { markContentDraftPublishedFor } from '@/lib/mcp/content-delivery';
import { failedCallResponse } from '@/lib/mcp/subscription-gate';
import { contentUuid } from '@/lib/mcp/content-schemas';
const body = z.object({ url: z.string().max(2048) });
/**
* POST /api/mcp/content-drafts/[id]/published — REST mirror of
* `mark_content_draft_published`. Body: { url }.
*/
export async function POST(req: Request, { params }: { params: Promise<{ id: string }> }) {
const auth = await authenticateMcpRequest(req);
if (auth instanceof NextResponse) return auth;
const { id } = await params;
const parsed = body.safeParse(await req.json().catch(() => ({})));
if (!contentUuid.safeParse(id).success || !parsed.success) {
return NextResponse.json({ error: 'Invalid request' }, { status: 400 });
}
try {
// Nothing written on the demo brand's sample data, as the tool refuses it.
const refused = await demoBrandRefusal('mark_content_draft_published', auth.organizationId, {
draft_id: id,
});
if (refused) return refused;
const result = await markContentDraftPublishedFor(auth, id, parsed.data.url);
if ('error' in result) {
return NextResponse.json(
{ error: result.message, code: result.error },
{ status: result.error === 'not_found' ? 404 : 400 },
);
}
return NextResponse.json(result);
} catch (err) {
return failedCallResponse(err);
}
}