Skip to main content
Glama

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
NameRequiredDescriptionDefault
media_urlNoPublic URL of the media to analyze
mediaNoBase64-encoded media content to analyze
textNoPlain text content to analyze for AI generation
mimeNoMIME type of the media (e.g. image/png, audio/wav, text/plain)
tagsNoTags for organizing and filtering

Implementation Reference

  • 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,
            };
          }
        },
      );
    }
  • 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);
  • 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),
      });
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sidearmDRM/mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server