cron_list
Lists all scheduled cron jobs from the MCP Cron Server, including optional disabled tasks for comprehensive task management.
Instructions
列出所有定时任务
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| includeDisabled | No | 包含禁用的任务 |
Implementation Reference
- src/index.ts:151-173 (handler)The cron_list tool handler that retrieves and formats the list of scheduled jobs. It takes an optional includeDisabled parameter and returns job details including id, name, enabled status, schedule, nextRun, lastRun, and lastStatus.
case 'cron_list': { const inputArgs = args as { includeDisabled?: boolean }; const jobs = scheduler.listJobs(inputArgs.includeDisabled || false); return { content: [ { type: 'text', text: JSON.stringify({ jobs: jobs.map(j => ({ id: j.id, name: j.name, enabled: j.enabled, schedule: j.schedule, nextRun: formatNextRun(j.state.nextRunAtMs), lastRun: j.state.lastRunAtMs ? new Date(j.state.lastRunAtMs).toISOString() : null, lastStatus: j.state.lastStatus })) }, null, 2) } ] }; } - src/index.ts:66-73 (schema)The input schema definition for the cron_list tool, which accepts an optional includeDisabled boolean parameter to control whether disabled jobs are included in the response.
name: 'cron_list', description: '列出所有定时任务', inputSchema: { type: 'object', properties: { includeDisabled: { type: 'boolean', description: '包含禁用的任务' } } } - src/scheduler.ts:120-122 (helper)The listJobs method in the CronScheduler class that retrieves jobs from the store, optionally including disabled jobs based on the includeDisabled parameter.
listJobs(includeDisabled: boolean = false): CronJob[] { return this.store.getJobs(includeDisabled); } - src/schedule.ts:65-95 (helper)The formatNextRun helper function that formats the next run timestamp into a human-readable format (seconds, minutes, hours, or date string) for display in the cron_list response.
export function formatNextRun(nextRunAtMs: number | null | undefined): string { if (!nextRunAtMs) return 'N/A'; const date = new Date(nextRunAtMs); const now = new Date(); const diff = nextRunAtMs - now.getTime(); if (diff < 0) { return 'Overdue'; } if (diff < 60000) { return `${Math.floor(diff / 1000)}s`; } if (diff < 3600000) { return `${Math.floor(diff / 60000)}m`; } if (diff < 86400000) { return `${Math.floor(diff / 3600000)}h`; } return date.toLocaleString('zh-CN', { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' }); }