Skip to main content
Glama

server_create_task

Schedule automated tasks for Minecraft servers using interval-based or cron-based timing. Configure commands, backups, restarts, starts, or stops to run at specified times.

Instructions

Create a scheduled task for a Minecraft server. Use interval_type with interval for simple schedules (e.g., every 6 hours), or set cron_string with empty interval_type for cron-based schedules (e.g., '0 3 * * *' for 3 AM daily).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
server_idYesServer ID or UUID
nameYesTask name
enabledNoWhether the task is active
actionYesAction type: command, backup, restart, start, stop
action_idNoID of the action target, if applicable
intervalNoInterval number (used with interval_type)
interval_typeNoInterval unit. Use empty string with cron_string for cron schedules.hours
start_timeNoStart time in HH:MM format
commandNoCommand to run (for command action type)
one_timeNoRun once then delete
cron_stringNoCron expression (e.g. '0 3 * * *'). Use with interval_type=''.
delayNoDelay in seconds before running

Implementation Reference

  • The tool `server_create_task` is registered and implemented in this block, using `server.tool` to define the input schema via zod and the handler function to POST the task data to the Crafty server API.
    server.tool(
      "server_create_task",
      "Create a scheduled task for a Minecraft server. Use interval_type with interval for simple schedules (e.g., every 6 hours), or set cron_string with empty interval_type for cron-based schedules (e.g., '0 3 * * *' for 3 AM daily).",
      {
        server_id: z.string().describe("Server ID or UUID"),
        name: z.string().describe("Task name"),
        enabled: z.boolean().default(true).describe("Whether the task is active"),
        action: z
          .string()
          .describe("Action type: command, backup, restart, start, stop"),
        action_id: z.string().optional().describe("ID of the action target, if applicable"),
        interval: z.number().default(1).describe("Interval number (used with interval_type)"),
        interval_type: z
          .enum(["hours", "minutes", "days", "reaction", ""])
          .default("hours")
          .describe("Interval unit. Use empty string with cron_string for cron schedules."),
        start_time: z.string().optional().describe("Start time in HH:MM format"),
        command: z
          .string()
          .optional()
          .describe("Command to run (for command action type)"),
        one_time: z.boolean().default(false).describe("Run once then delete"),
        cron_string: z
          .string()
          .optional()
          .describe("Cron expression (e.g. '0 3 * * *'). Use with interval_type=''."),
        delay: z.number().default(0).describe("Delay in seconds before running"),
      },
      async ({ server_id, ...taskData }) => {
        try {
          const data = await client.post(`/servers/${server_id}/tasks`, taskData);
          return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
        } catch (error) {
          const msg = error instanceof Error ? error.message : String(error);
          return { content: [{ type: "text", text: `Error: ${msg}` }], isError: true };
        }
      }
    );

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/HadiCherkaoui/crafty-mcp'

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