detect_ai
Analyze media content to identify AI-generated material across images, video, audio, and text formats using specialized detection models.
Instructions
Detect whether media content was generated by AI. Supports images, video, audio, and text/PDF. Runs multiple specialized detection models in parallel for the given media type. Returns a job_id — use check_job to poll for results.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| media_url | No | Public URL of the media to analyze | |
| media | No | Base64-encoded media content to analyze | |
| text | No | Plain text content to analyze for AI generation | |
| mime | No | MIME type of the media (e.g. image/png, audio/wav, text/plain) | |
| tags | No | Tags for organizing and filtering |
Implementation Reference
- src/tools/detect-ai.ts:5-70 (handler)Main implementation of detect_ai tool - defines the tool with Zod schema for input validation (media_url, media, text, mime, tags) and the handler function that posts to /api/v1/detect/ai endpoint, returning a job_id for polling via check_job
export function register(server: McpServer, api: ApiClient): void { server.tool( "detect_ai", "Detect whether media content was generated by AI. Supports images, video, audio, " + "and text/PDF. Runs multiple specialized detection models in parallel for the given " + "media type. Returns a job_id — use check_job to poll for results.", { media_url: z .string() .url() .optional() .describe("Public URL of the media to analyze"), media: z .string() .optional() .describe("Base64-encoded media content to analyze"), text: z .string() .optional() .describe("Plain text content to analyze for AI generation"), mime: z .string() .optional() .describe("MIME type of the media (e.g. image/png, audio/wav, text/plain)"), tags: z .array(z.string()) .optional() .describe("Tags for organizing and filtering"), }, async (params) => { try { const body: Record<string, unknown> = {}; if (params.media_url) body.media_url = params.media_url; if (params.media) body.media = params.media; if (params.text) body.text = params.text; if (params.mime) body.mime = params.mime; if (params.tags) body.tags = params.tags; const result = await api.post("/api/v1/detect/ai", body); const res = result as { job_id: string }; return { content: [ { type: "text" as const, text: `AI detection job created.\n\n` + `Job ID: ${res.job_id}\n\n` + `Use check_job with this job_id to poll for results.`, }, ], }; } catch (err) { return { content: [ { type: "text" as const, text: `Error: ${err instanceof Error ? err.message : String(err)}`, }, ], isError: true as const, }; } }, ); } - src/tools/detect-ai.ts:12-33 (schema)Zod input schema definition for detect_ai tool parameters including optional media_url, media, text, mime type, and tags fields
media_url: z .string() .url() .optional() .describe("Public URL of the media to analyze"), media: z .string() .optional() .describe("Base64-encoded media content to analyze"), text: z .string() .optional() .describe("Plain text content to analyze for AI generation"), mime: z .string() .optional() .describe("MIME type of the media (e.g. image/png, audio/wav, text/plain)"), tags: z .array(z.string()) .optional() .describe("Tags for organizing and filtering"), }, - src/index.ts:12-12 (registration)Import statement for detect_ai register function
import { register as detectAi } from "./tools/detect-ai.js"; - src/index.ts:54-54 (registration)Registration of detect_ai tool with the MCP server instance and API client
detectAi(server, api); - src/api.ts:25-31 (helper)ApiClient.post method used by detect_ai handler to make API requests to the SDRM API endpoint
async post<T = unknown>(path: string, body: unknown): Promise<T> { return this.request<T>(new URL(`${this.baseUrl}${path}`), { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body), }); }