Skip to main content
Glama

create_job

Create a new agent job by specifying job type, target channel, and optional parameters to initiate automated tasks on platforms like WhatsApp, Slack, or web.

Instructions

Create a new Agent Job with the minimal set of fields.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
job_type_idYesID of the job type (e.g. "mood-monitor")
target_channelYesWhere the agent will communicate.
paramsNoFree‑form params passed to the agent
scheduled_atNoSchedule the job to run later

Implementation Reference

  • The handler function that processes the input parameters, calls the agentJobsClient to create the job, logs debugging info, and returns a text response with job ID or error.
    async (params) => {
      mcpDebugger.toolCall("create_job", params);
    
      // Fall back to default org if none supplied.
      params.target_channel.org_id ??= config.DEFAULT_ORG_ID;
    
      mcpDebugger.debug("Job creation payload", {
        job_type_id: params.job_type_id,
        target_channel: params.target_channel,
        scheduled_at: params.scheduled_at,
        paramsCount: params.params ? Object.keys(params.params).length : 0
      });
    
      try {
        const res = await withTiming(
          () => agentJobsClient.post('/services/agent-jobs', params),
          "create_job API call"
        );
    
        const jobId = res.id ?? 'unknown';
    
        mcpDebugger.debug("Job creation response", { jobId, fullResponse: res });
    
        const result = {
          content: [
            {
              type: 'text' as const,
              text: `✅ Job created (id: ${jobId}).`
            }
          ]
        };
    
        mcpDebugger.toolResponse("create_job", { jobId });
    
        return result;
      } catch (error: any) {
        mcpDebugger.toolError("create_job", error);
    
        return {
          content: [
            {
              type: 'text' as const,
              text: `Error creating job: ${error.message}`
            }
          ]
        };
      }
    }
  • Input schema using Zod for validating job_type_id, target_channel (with platform, code, org_id), optional params and scheduled_at.
    inputSchema: {
      // Required fields
      job_type_id: z
        .string()
        .describe('ID of the job type (e.g. "mood-monitor")'),
    
      target_channel: z
        .object({
          platform: z
            .enum(['whatsapp', 'slack', 'web'])
            .describe('Destination platform.'),
          code: z
            .string()
            .describe('Channel identifier, phone number, or user ID.'),
          org_id: z
            .string()
            .optional()
            .describe('Org ID – defaults to config.DEFAULT_ORG_ID')
        })
        .describe('Where the agent will communicate.'),
    
      params: z
        .record(z.any())
        .optional()
        .describe('Free‑form params passed to the agent'),
      scheduled_at: flexibleDateTimeSchema
        .optional()
        .describe('Schedule the job to run later')
    }
  • Module that registers the create_job tool with the MCP server, providing name, description, schema, and handler function.
    export default (server: McpServer) => {
      server.registerTool(
        'create_job',
        {
          description: 'Create a new Agent Job with the minimal set of fields.',
          annotations: {
            title: 'Create Agent Job'
          },
          inputSchema: {
            // Required fields
            job_type_id: z
              .string()
              .describe('ID of the job type (e.g. "mood-monitor")'),
    
            target_channel: z
              .object({
                platform: z
                  .enum(['whatsapp', 'slack', 'web'])
                  .describe('Destination platform.'),
                code: z
                  .string()
                  .describe('Channel identifier, phone number, or user ID.'),
                org_id: z
                  .string()
                  .optional()
                  .describe('Org ID – defaults to config.DEFAULT_ORG_ID')
              })
              .describe('Where the agent will communicate.'),
    
            params: z
              .record(z.any())
              .optional()
              .describe('Free‑form params passed to the agent'),
            scheduled_at: flexibleDateTimeSchema
              .optional()
              .describe('Schedule the job to run later')
          }
        },
        async (params) => {
          mcpDebugger.toolCall("create_job", params);
    
          // Fall back to default org if none supplied.
          params.target_channel.org_id ??= config.DEFAULT_ORG_ID;
    
          mcpDebugger.debug("Job creation payload", {
            job_type_id: params.job_type_id,
            target_channel: params.target_channel,
            scheduled_at: params.scheduled_at,
            paramsCount: params.params ? Object.keys(params.params).length : 0
          });
    
          try {
            const res = await withTiming(
              () => agentJobsClient.post('/services/agent-jobs', params),
              "create_job API call"
            );
    
            const jobId = res.id ?? 'unknown';
    
            mcpDebugger.debug("Job creation response", { jobId, fullResponse: res });
    
            const result = {
              content: [
                {
                  type: 'text' as const,
                  text: `✅ Job created (id: ${jobId}).`
                }
              ]
            };
    
            mcpDebugger.toolResponse("create_job", { jobId });
    
            return result;
          } catch (error: any) {
            mcpDebugger.toolError("create_job", error);
    
            return {
              content: [
                {
                  type: 'text' as const,
                  text: `Error creating job: ${error.message}`
                }
              ]
            };
          }
        }
      );
    };
Behavior2/5

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

Annotations only provide a title, so the description carries full burden. It states this creates a new job but lacks behavioral details like required permissions, whether it's idempotent, what happens on failure, or if it triggers immediate execution. The mention of 'minimal set of fields' hints at constraints but is vague.

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 a single, efficient sentence that front-loads the core purpose without unnecessary words. It's appropriately sized for a tool with good schema coverage, making every word count.

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

Completeness3/5

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

Given no output schema and minimal annotations, the description is incomplete for a creation tool. It covers the basic action but lacks details on return values, error handling, or behavioral traits, leaving gaps that could hinder agent usage despite good schema coverage.

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 fully documents parameters. The description adds no additional meaning beyond implying 'minimal fields' might relate to required parameters, but it doesn't clarify which fields are minimal or provide usage context beyond the schema.

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

Purpose4/5

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

The description clearly states the action ('Create') and resource ('Agent Job'), specifying it's a new job with minimal fields. It distinguishes from siblings like 'cancel_job' or 'get_job' by being the creation tool, though it doesn't explicitly contrast with 'list_jobs' or 'get_jobs_stats'.

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

Usage Guidelines2/5

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

No guidance on when to use this tool versus alternatives is provided. It doesn't mention prerequisites, dependencies, or contrast with sibling tools like 'list_jobs' for viewing existing jobs or 'cancel_job' for stopping them, leaving the agent to infer usage context.

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/aiconnect-cloud/agentjobs-mcp'

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