@chinchillaenterprises/mcp-lambda-cron
v1.0.4
Published
MCP server for managing AWS Lambda cron jobs with EventBridge
Readme
MCP Lambda Cron
An MCP server for managing AWS Lambda cron jobs and scheduled events using EventBridge. This tool allows you to create, manage, and monitor scheduled executions of your Lambda functions with both simple cron expressions and advanced scheduling features.
Features
- Multi-Account Support: Manage cron jobs across multiple AWS accounts
- Cron & Rate Schedules: Create both cron-based and rate-based schedules
- EventBridge Integration: Full integration with AWS EventBridge for reliable scheduling
- Advanced Scheduling: Support for time zones, flexible time windows, and date ranges
- Lambda Management: List functions, manage permissions automatically
- Secure Credential Storage: Uses system keychain (Keytar) with encrypted file fallback
Installation
npm install -g @chinchillaenterprises/mcp-lambda-cronOr use with Claude:
claude mcp add lambda-cron @chinchillaenterprises/mcp-lambda-cronAWS Setup
Before using this tool, ensure you have:
AWS credentials with permissions for:
- EventBridge (events:*)
- Lambda (lambda:*)
- EventBridge Scheduler (scheduler:*) - for advanced schedules
- STS (sts:GetCallerIdentity)
Lambda functions already deployed that you want to schedule
Usage
Account Management
// Add a new AWS account
await add_account({
name: "Production",
accessKeyId: "AKIAIOSFODNN7EXAMPLE",
secretAccessKey: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
region: "us-east-1"
});
// List all configured accounts
await list_accounts();
// Switch to a different account
await switch_account({ accountId: "account-id" });
// Get current active account
await get_active_account();Creating Cron Jobs
// Create a cron job (runs daily at noon UTC)
await create_cron_rule({
ruleName: "daily-report-generator",
cronExpression: "0 12 * * ? *",
functionName: "generateDailyReport",
description: "Generate daily reports at noon",
enabled: true,
input: JSON.stringify({ reportType: "daily" })
});
// Create a rate-based schedule (runs every 5 minutes)
await create_rate_rule({
ruleName: "health-check",
rateExpression: "5 minutes",
functionName: "healthCheck",
description: "Regular health check"
});Cron Expression Examples
0 12 * * ? *- Daily at noon UTC0 0 * * ? *- Daily at midnight UTC0 */2 * * ? *- Every 2 hours0 9 ? * MON-FRI *- Weekdays at 9 AM UTC0 0 1 * ? *- First day of every month
Rate Expression Examples
5 minutes- Every 5 minutes1 hour- Every hour7 days- Weekly30 days- Monthly
Managing Rules
// List all rules
await list_rules();
// List rules for a specific function
await list_rules({ targetFunction: "myFunction" });
// Get detailed information about a rule
await get_rule_details({ ruleName: "daily-report-generator" });
// Disable a rule temporarily
await disable_rule({ ruleName: "daily-report-generator" });
// Enable a disabled rule
await enable_rule({ ruleName: "daily-report-generator" });
// Update a rule's schedule
await update_rule_schedule({
ruleName: "daily-report-generator",
scheduleExpression: "cron(0 14 * * ? *)" // Change to 2 PM
});
// Delete a rule
await delete_rule({
ruleName: "daily-report-generator",
functionName: "generateDailyReport" // Optional, for cleaning permissions
});Advanced Scheduling (Time Zones & Flexible Windows)
// Create schedule with timezone support
await create_advanced_schedule({
scheduleName: "business-hours-task",
scheduleExpression: "cron(0 9 ? * MON-FRI *)",
functionArn: "arn:aws:lambda:us-east-1:123456789012:function:myFunction",
timezone: "America/New_York", // Runs at 9 AM ET instead of UTC
flexibleTimeWindow: 15, // Can run up to 15 minutes after scheduled time
startDate: "2024-01-01T00:00:00Z",
endDate: "2024-12-31T23:59:59Z",
input: JSON.stringify({ mode: "business-hours" })
});Lambda Function Management
// List all Lambda functions
await list_lambda_functions();
// List functions with a specific prefix
await list_lambda_functions({ functionNamePrefix: "prod-" });Tool Reference
Account Management Tools
add_account- Add a new AWS account configurationlist_accounts- List all configured AWS accountsswitch_account- Switch to a different AWS accountremove_account- Remove an AWS account configurationget_active_account- Get the currently active AWS accountset_default_account- Set an account as the default
Scheduling Tools
create_cron_rule- Create a cron-based schedulecreate_rate_rule- Create a rate-based schedulecreate_advanced_schedule- Create advanced schedule with timezone and flexible windowsdelete_rule- Delete a scheduling rulelist_rules- List all EventBridge rulesget_rule_details- Get details about a specific ruleenable_rule- Enable a disabled ruledisable_rule- Disable an active ruleupdate_rule_schedule- Update the schedule expressionlist_lambda_functions- List available Lambda functions
Security Considerations
- Credentials are stored securely using the system keychain (via Keytar)
- Fallback to encrypted file storage using AES-256-CBC encryption
- Never commit AWS credentials to version control
- Use IAM roles with minimal required permissions
- Regular credential rotation is recommended
Troubleshooting
Common Issues
"Policy contains a statement with one or more invalid principals"
- Ensure your Lambda function exists in the specified region
- Check that the function name is correct
"Rule already exists"
- EventBridge rule names must be unique per region
- Delete the existing rule or use a different name
"Access Denied"
- Verify your AWS credentials have the required permissions
- Check the account and region settings
Advanced Schedules Not Working
- Ensure you have created the required IAM role for EventBridge Scheduler
- The role needs permission to invoke Lambda functions
Contributing
Contributions are welcome! Please submit issues and pull requests on GitHub.
License
MIT
