Enables AI task generation through OpenAI models (with default model gpt-4o), allowing scheduled creation of AI-generated content.
Provides a programmatic API client for Python applications to interact with the scheduler, supporting task creation, management, and monitoring through Python code.
Uses SQLite database for persistent storage of tasks and execution history, with configurable database path.
MCP Scheduler
A robust task scheduler server built with Model Context Protocol (MCP) for scheduling and managing various types of automated tasks.
Fork from https://github.com/PhialsBasement/scheduler-mcp
Overview
MCP Scheduler is a versatile task automation system that allows you to schedule and run different types of tasks:
- Shell Commands: Execute system commands on a schedule
- API Calls: Make HTTP requests to external services
- AI Tasks: Generate content through OpenAI models
- Reminders: Display desktop notifications with sound
The scheduler uses cron expressions for flexible timing and provides a complete history of task executions. It's built on the Model Context Protocol (MCP), making it easy to integrate with AI assistants and other MCP-compatible clients.
Features
- Multiple Task Types: Support for shell commands, API calls, AI content generation, and desktop notifications
- Cron Scheduling: Familiar cron syntax for precise scheduling control
- Run Once or Recurring: Option to run tasks just once or repeatedly on schedule
- Execution History: Track successful and failed task executions
- Cross-Platform: Works on Windows, macOS, and Linux
- Interactive Notifications: Desktop alerts with sound for reminder tasks
- MCP Integration: Seamless connection with AI assistants and tools
- Robust Error Handling: Comprehensive logging and error recovery
Installation
Prerequisites
- Python 3.10 or higher
- uv (recommended package manager)
Installing uv (recommended)
After installing uv, restart your terminal to ensure the command is available.
Project Setup with uv (recommended)
Standard pip installation (alternative)
If you prefer using standard pip:
Usage
Running the Server
The server uses stdio transport by default, which is ideal for integration with Amazon Q and other MCP clients. The server automatically handles the communication protocol based on the environment.
Integrating with Amazon Q, Claude Desktop or other MCP Clients
Amazon Q Integration
To use MCP Scheduler with Amazon Q:
- Make sure you have Amazon Q CLI installed
- Run the scheduler with the AWS Q model patch:
This will automatically register the scheduler with Amazon Q, allowing you to create and manage tasks through natural language commands.
Example commands:
- "Create a scheduled task to backup my config file every night at 10:30 PM"
- "Show me all my scheduled tasks"
- "Run the backup task now"
See the examples
directory for more usage examples with Amazon Q.
Claude Desktop Integration
To use your MCP Scheduler with Claude Desktop:
- Make sure you have Claude Desktop installed
- Open your Claude Desktop App configuration at:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:
%APPDATA%\Claude\claude_desktop_config.json
- macOS:
- Create the file if it doesn't exist, and add your server:
Alternatively, use the fastmcp
utility if you're using the FastMCP library:
Command Line Options
When using with Amazon Q, most of these options are automatically configured by the start_with_aws_q.py
script.
--config Path to JSON configuration file
--ai-model AI model to use for AI tasks (default: gpt-4o)
--version Show version and exit
--debug Enable debug mode with full traceback
--fix-json Enable JSON fixing for malformed messages
When using with Amazon Q, the use_aws_q_model
should be set to true
and no API key is required.
重要说明
任务类型和限制
MCP Scheduler是一个应用级任务调度服务,而不是系统级定时任务管理器:
- 应用级任务:MCP Scheduler创建的任务存储在其自己的数据库中,只有在MCP Scheduler服务运行时才会执行
- 非系统级:这些任务不是系统crontab或systemd定时器,不会在系统启动时自动运行
- 服务依赖:如果MCP Scheduler服务停止,任务将不会执行
- 用户权限:任务以运行MCP Scheduler的用户权限执行,而不是root权限
如果您需要系统级定时任务(在系统启动时自动运行或需要root权限),请考虑:
- 使用操作系统的
crontab -e
或systemctl
直接创建系统级定时任务 - 创建一个MCP Scheduler任务,该任务执行脚本来管理系统级定时任务
持久化和服务管理
为确保MCP Scheduler在系统重启后继续运行,您可以:
- 将其设置为系统服务(使用systemd)
- 在用户登录时自动启动
- 在云环境中作为容器或服务运行
MCP Tool Functions
The MCP Scheduler provides the following tools:
Task Management
list_tasks
: Get all scheduled tasksget_task
: Get details of a specific taskadd_command_task
: Add a new shell command taskadd_api_task
: Add a new API call taskadd_ai_task
: Add a new AI taskadd_reminder_task
: Add a new reminder task with desktop notificationupdate_task
: Update an existing taskremove_task
: Delete a taskenable_task
: Enable a disabled taskdisable_task
: Disable an active taskrun_task_now
: Run a task immediately
Execution and Monitoring
get_task_executions
: Get execution history for a taskget_server_info
: Get server information
Cron Expression Guide
MCP Scheduler uses standard cron expressions for scheduling. Here are some examples:
0 0 * * *
- Daily at midnight0 */2 * * *
- Every 2 hours0 9-17 * * 1-5
- Every hour from 9 AM to 5 PM, Monday to Friday0 0 1 * *
- At midnight on the first day of each month0 0 * * 0
- At midnight every Sunday
Environment Variables
The scheduler can be configured using environment variables:
MCP_SCHEDULER_NAME
: Server name (default: mcp-scheduler)MCP_SCHEDULER_VERSION
: Server version (default: 0.1.0)MCP_SCHEDULER_ADDRESS
: Server address (default: localhost)MCP_SCHEDULER_PORT
: Server port (default: 8080)MCP_SCHEDULER_TRANSPORT
: Transport mode (default: stdio)MCP_SCHEDULER_LOG_LEVEL
: Logging level (default: INFO)MCP_SCHEDULER_LOG_FILE
: Log file pathMCP_SCHEDULER_DB_PATH
: Database path (default: scheduler.db)MCP_SCHEDULER_CHECK_INTERVAL
: How often to check for tasks (default: 5 seconds)MCP_SCHEDULER_EXECUTION_TIMEOUT
: Task execution timeout (default: 300 seconds)MCP_SCHEDULER_AI_MODEL
: OpenAI model for AI tasks (default: gpt-4o)MCP_SCHEDULER_USE_AWS_Q_MODEL
: Use AWS Q model for AI tasks (default: false)OPENAI_API_KEY
: API key for OpenAI tasks (not needed when using AWS Q model)
Examples
MCP Scheduler可以通过两种方式使用:通过Amazon Q等MCP客户端的自然语言交互,或者通过编程方式直接调用API。
通过Amazon Q使用(推荐)
使用Amazon Q创建和管理任务非常简单,只需使用自然语言描述您想要的任务:
- 创建命令任务:
- 创建API调用任务:
- 创建AI任务:
- 创建提醒任务:
- 查看所有任务:
- 立即运行任务:
通过编程API使用
如果您正在开发应用程序或脚本,可以通过编程方式与MCP Scheduler交互。以下是建立调用关系的简要指南:
1. 安装必要的依赖
2. 建立连接并调用API
3. 连接到已运行的MCP Scheduler
如果MCP Scheduler已经在HTTP模式下运行,可以使用SSE客户端连接:
4. 错误处理
完整示例
查看 examples/api_client_example.py
获取完整的API使用示例,包括:
- 连接到MCP Scheduler服务
- 创建、运行、更新和删除任务
- 获取任务执行历史
- 错误处理和异常管理
示例脚本
examples
目录包含了可直接使用的脚本和配置,适用于常见用例:
backup_mcp_config.sh
:一个用于备份Amazon Q MCP配置文件的脚本,包含基于日期的命名和保留策略
MCP Tool Discovery
MCP Scheduler supports automatic tool discovery through the Model Context Protocol:
Stdio Mode (Default)
When running in stdio mode (the default), tool discovery happens automatically through the MCP protocol. This is the recommended mode for use with Amazon Q and other MCP clients that support stdio communication.
HTTP Mode (Optional)
If you need to run the server in HTTP mode, you can use the SSE transport and access the schema through the well-known endpoint:
In HTTP mode, the server exposes a well-known endpoint for tool/schema auto-discovery:
- Endpoint:
/.well-known/mcp-schema.json
(on the HTTP port + 1, e.g., if your server runs on 8080, the schema is on 8081) - Purpose: Allows clients and AI assistants to discover all available MCP tools and their parameters automatically.
You can access the schema at:
Example Schema Response
This schema is generated automatically from the registered MCP tools and always reflects the current server capabilities.
Development
If you want to contribute or develop the MCP Scheduler further, here are some additional commands:
License
This project is licensed under the MIT License - see the LICENSE file for details.
This server cannot be installed
A robust task scheduler server built with Model Context Protocol for scheduling and managing various types of automated tasks including shell commands, API calls, AI tasks, and reminders.
Related MCP Servers
- -securityFlicense-qualityA versatile Model Context Protocol server that enables AI assistants to manage calendars, track tasks, handle emails, search the web, and control smart home devices.Last updated -13Python
- -securityFlicense-qualityA Model Context Protocol server that provides persistent task management capabilities for AI assistants, allowing them to create, update, and track tasks beyond their usual context limitations.Last updated -3TypeScript
- -securityAlicense-qualityA Model Context Protocol server providing comprehensive task management capabilities with support for project organization, task tracking, and automatic PRD parsing into actionable items.Last updated -16PythonMIT License
- AsecurityAlicenseAqualityA Model Context Protocol server providing AI assistants with comprehensive project, task, and subtask management capabilities with project-specific storage.Last updated -292542TypeScriptMIT License