Skip to main content
Glama

check_job

Monitor the status and retrieve results for asynchronous jobs like algorithm execution, media protection, or AI detection tasks. Returns progress, completion status, and download links when ready.

Instructions

Check the status of an asynchronous job (from run_algorithm, protect_media, or detect_ai). Returns status (queued, processing, completed, failed), progress percentage, and result data including download URLs when complete.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
job_idYesThe job ID returned by a previous tool call

Implementation Reference

  • Main handler function for check_job tool that polls the API for job status, formats the response with status, progress, timestamps, and result data, and handles errors.
    async ({ job_id }) => {
      try {
        const result = (await api.get(
          `/api/v1/jobs/${encodeURIComponent(job_id)}`,
        )) as JobResponse;
    
        const lines: string[] = [
          `Status: ${result.status}`,
        ];
    
        if (result.progress !== undefined) {
          lines.push(`Progress: ${result.progress}%`);
        }
        if (result.created_at) {
          lines.push(`Created: ${result.created_at}`);
        }
        if (result.completed_at) {
          lines.push(`Completed: ${result.completed_at}`);
        }
        if (result.error) {
          lines.push(`\nError: ${result.error}`);
        }
        if (result.result) {
          lines.push(`\nResult:\n${JSON.stringify(result.result, null, 2)}`);
        }
    
        if (result.status === "queued" || result.status === "processing") {
          lines.push(`\nJob is still running. Call check_job again in a few seconds.`);
        }
    
        return {
          content: [{ type: "text" as const, text: lines.join("\n") }],
        };
      } catch (err) {
        return {
          content: [
            {
              type: "text" as const,
              text: `Error: ${err instanceof Error ? err.message : String(err)}`,
            },
          ],
          isError: true as const,
        };
      }
    },
  • Input schema definition using zod that validates the job_id parameter as a string.
      job_id: z.string().describe("The job ID returned by a previous tool call"),
    },
  • TypeScript interface JobResponse that defines the structure of the API response including id, status, progress, result, error, and timestamps.
    interface JobResponse {
      id: string;
      status: string;
      progress?: number;
      result?: unknown;
      error?: string;
      created_at?: string;
      completed_at?: string;
    }
  • Tool registration with server.tool() that registers the check_job tool with its name, description, input schema, and handler function.
    server.tool(
      "check_job",
      "Check the status of an asynchronous job (from run_algorithm, protect_media, or detect_ai). " +
        "Returns status (queued, processing, completed, failed), progress percentage, " +
        "and result data including download URLs when complete.",
      {
        job_id: z.string().describe("The job ID returned by a previous tool call"),
      },
      async ({ job_id }) => {
        try {
          const result = (await api.get(
            `/api/v1/jobs/${encodeURIComponent(job_id)}`,
          )) as JobResponse;
    
          const lines: string[] = [
            `Status: ${result.status}`,
          ];
    
          if (result.progress !== undefined) {
            lines.push(`Progress: ${result.progress}%`);
          }
          if (result.created_at) {
            lines.push(`Created: ${result.created_at}`);
          }
          if (result.completed_at) {
            lines.push(`Completed: ${result.completed_at}`);
          }
          if (result.error) {
            lines.push(`\nError: ${result.error}`);
          }
          if (result.result) {
            lines.push(`\nResult:\n${JSON.stringify(result.result, null, 2)}`);
          }
    
          if (result.status === "queued" || result.status === "processing") {
            lines.push(`\nJob is still running. Call check_job again in a few seconds.`);
          }
    
          return {
            content: [{ type: "text" as const, text: lines.join("\n") }],
          };
        } catch (err) {
          return {
            content: [
              {
                type: "text" as const,
                text: `Error: ${err instanceof Error ? err.message : String(err)}`,
              },
            ],
            isError: true as const,
          };
        }
      },
    );
  • src/index.ts:9-47 (registration)
    Import and registration call of the check_job tool in the main server initialization file.
    import { register as checkJob } from "./tools/check-job.js";
    import { register as searchMedia } from "./tools/search-media.js";
    import { register as listSearches } from "./tools/list-searches.js";
    import { register as detectAi } from "./tools/detect-ai.js";
    import { register as detectFingerprint } from "./tools/detect-fingerprint.js";
    import { register as detectMembership } from "./tools/detect-membership.js";
    import { register as registerMedia } from "./tools/register-media.js";
    import { register as listMedia } from "./tools/list-media.js";
    import { register as getMedia } from "./tools/get-media.js";
    import { register as updateMedia } from "./tools/update-media.js";
    import { register as deleteMedia } from "./tools/delete-media.js";
    import { register as getRights } from "./tools/get-rights.js";
    import { register as getBilling } from "./tools/get-billing.js";
    
    const apiKey = process.env.SDRM_API_KEY;
    if (!apiKey) {
      process.stderr.write(
        "Error: SDRM_API_KEY environment variable is required.\n" +
          "Get your API key at https://sdrm.io/api-keys\n",
      );
      process.exit(1);
    }
    
    const api = new ApiClient(apiKey, process.env.SDRM_BASE_URL);
    
    const server = new McpServer({
      name: "sdrm",
      version: "0.1.0",
    });
    
    // Discovery
    listAlgorithms(server, api);
    
    // Protection
    runAlgorithm(server, api);
    protectMedia(server, api);
    
    // Jobs
    checkJob(server, api);
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses key behavioral traits: it's a read operation (checking status), returns specific status values (queued, processing, completed, failed), progress percentage, and result data including download URLs. However, it doesn't mention error handling, rate limits, authentication needs, or whether the job ID must be from the current session.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is perfectly concise and front-loaded: the first clause states the core purpose, followed by essential details about return values. Every sentence earns its place with no wasted words, and the structure moves from general to specific efficiently.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a single-parameter read tool with no output schema, the description provides good completeness: it explains the purpose, when to use it, and what it returns. However, it doesn't specify the format of result data or download URLs, and with no annotations, some behavioral aspects like error cases remain uncovered.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents the single parameter 'job_id' as 'The job ID returned by a previous tool call.' The description adds context by listing which previous tools (run_algorithm, protect_media, detect_ai) provide these job IDs, which adds some semantic value beyond the schema. Baseline 3 is appropriate when schema coverage is high.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('check the status') and resources ('asynchronous job'), and distinguishes it from siblings by listing the specific job-creating tools (run_algorithm, protect_media, detect_ai). It goes beyond a simple tautology of the name 'check_job' by specifying what kind of job it checks.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context on when to use this tool: after calling run_algorithm, protect_media, or detect_ai, when you have a job ID. It implicitly distinguishes from siblings by referencing those specific tools. However, it doesn't explicitly state when NOT to use it or mention alternatives for job status checking.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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