MCP Scheduler
A robust task scheduler server for scheduling and managing various types of automated tasks including shell commands, API calls, AI tasks, and reminders.
README
MCP Scheduler
A robust task scheduler server built with Model Context Protocol (MCP) for scheduling and managing various types of automated tasks.
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)
# For Mac/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# For Windows (PowerShell)
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
After installing uv, restart your terminal to ensure the command is available.
Project Setup
# Clone the repository
git clone https://github.com/phialsbasement/mcp-scheduler.git
cd mcp-scheduler
# Create and activate a virtual environment with uv
uv venv
source .venv/bin/activate # On Unix/MacOS
# or
.venv\Scripts\activate # On Windows
# Install dependencies with uv
uv pip install -r requirements.txt
Standard pip installation (alternative)
If you prefer using standard pip:
# Clone the repository
git clone https://github.com/phialsbasement/mcp-scheduler.git
cd mcp-scheduler
# Create and activate a virtual environment
python -m venv .venv
source .venv/bin/activate # On Unix/MacOS
# or
.venv\Scripts\activate # On Windows
# Install dependencies
pip install -r requirements.txt
Usage
Running the Server
# Run with default settings (stdio transport)
python main.py
# Run with server transport on specific port
python main.py --transport sse --port 8080
# Run with debug mode for detailed logging
python main.py --debug
Integrating with Claude Desktop or other MCP Clients
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:
{
"mcpServers": [
{
"type": "stdio",
"name": "MCP Scheduler",
"command": "python",
"args": ["/path/to/your/mcp-scheduler/main.py"]
}
]
}
Alternatively, use the fastmcp utility if you're using the FastMCP library:
# Install your server in Claude Desktop
fastmcp install main.py --name "Task Scheduler"
Command Line Options
--address Server address (default: localhost)
--port Server port (default: 8080)
--transport Transport mode (sse or stdio) (default: stdio)
--log-level Logging level (default: INFO)
--log-file Log file path (default: mcp_scheduler.log)
--db-path SQLite database path (default: scheduler.db)
--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
Configuration File
You can use a JSON configuration file instead of command-line arguments:
{
"server": {
"name": "mcp-scheduler",
"version": "0.1.0",
"address": "localhost",
"port": 8080,
"transport": "sse"
},
"database": {
"path": "scheduler.db"
},
"logging": {
"level": "INFO",
"file": "mcp_scheduler.log"
},
"scheduler": {
"check_interval": 5,
"execution_timeout": 300
},
"ai": {
"model": "gpt-4o",
"openai_api_key": "your-api-key"
}
}
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)OPENAI_API_KEY: API key for OpenAI tasks
Examples
Adding a Shell Command Task
await scheduler.add_command_task(
name="Backup Database",
schedule="0 0 * * *", # Midnight every day
command="pg_dump -U postgres mydb > /backups/mydb_$(date +%Y%m%d).sql",
description="Daily database backup",
do_only_once=False # Recurring task
)
Adding an API Task
await scheduler.add_api_task(
name="Fetch Weather Data",
schedule="0 */6 * * *", # Every 6 hours
api_url="https://api.weather.gov/stations/KJFK/observations/latest",
api_method="GET",
description="Get latest weather observations",
do_only_once=False
)
Adding an AI Task
await scheduler.add_ai_task(
name="Generate Weekly Report",
schedule="0 9 * * 1", # 9 AM every Monday
prompt="Generate a summary of the previous week's sales data.",
description="Weekly sales report generation",
do_only_once=False
)
Adding a Reminder Task
await scheduler.add_reminder_task(
name="Team Meeting",
schedule="30 9 * * 2,4", # 9:30 AM every Tuesday and Thursday
message="Don't forget the team standup meeting!",
title="Meeting Reminder",
do_only_once=False
)
MCP Auto-discovery Endpoint
When running in SSE (HTTP) mode, MCP Scheduler 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.
Example
If you run:
python main.py --transport sse --port 8080
You can access the schema at:
http://localhost:8081/.well-known/mcp-schema.json
Example Response
{
"tools": [
{
"name": "list_tasks",
"description": "List all scheduled tasks.",
"endpoint": "list_tasks",
"method": "POST",
"parameters": {
"type": "object",
"properties": {},
"required": [],
"additionalProperties": false
}
},
{
"name": "add_command_task",
"description": "Add a new shell command task.",
"endpoint": "add_command_task",
"method": "POST",
"parameters": {
"type": "object",
"properties": {
"name": {"type": "string"},
"schedule": {"type": "string"},
"command": {"type": "string"},
"description": {"type": "string"},
"enabled": {"type": "boolean"},
"do_only_once": {"type": "boolean"}
},
"required": ["name", "schedule", "command"],
"additionalProperties": false
}
}
// ... more tools ...
]
}
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:
# Install the MCP SDK for development
uv pip install "mcp[cli]>=1.4.0"
# Or for FastMCP (alternative implementation)
uv pip install fastmcp
# Testing your MCP server
# With the MCP Inspector tool
mcp inspect --stdio -- python main.py
# Or with a simple MCP client
python -m mcp.client.stdio python main.py
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Built on the Model Context Protocol
- Uses croniter for cron parsing
- Uses OpenAI API for AI tasks
- Uses FastMCP for enhanced MCP functionality
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。