Skip to main content
Glama

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
NameRequiredDescriptionDefault
includeDisabledNo包含禁用的任务

Implementation Reference

  • 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)
          }
        ]
      };
    }
  • 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: '包含禁用的任务' }
      }
    }
  • 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);
    }
  • 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' 
      });
    }

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/nolan57/opencode-mcp-cron'

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