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
| Name | Required | Description | Default |
|---|---|---|---|
| server_id | Yes | Server ID or UUID | |
| name | Yes | Task name | |
| enabled | No | Whether the task is active | |
| action | Yes | Action type: command, backup, restart, start, stop | |
| action_id | No | ID of the action target, if applicable | |
| interval | No | Interval number (used with interval_type) | |
| interval_type | No | Interval unit. Use empty string with cron_string for cron schedules. | hours |
| start_time | No | Start time in HH:MM format | |
| command | No | Command to run (for command action type) | |
| one_time | No | Run once then delete | |
| cron_string | No | Cron expression (e.g. '0 3 * * *'). Use with interval_type=''. | |
| delay | No | Delay in seconds before running |
Implementation Reference
- src/tools/server-tasks.ts:39-76 (handler)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 }; } } );