mcp-cron 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +271 -0
- package/package.json +7 -7
package/README.md
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
# MCP Cron
|
|
2
|
+
|
|
3
|
+
Model Context Protocol (MCP) server for scheduling and managing tasks through a standardized API. The server provides task scheduling capabilities supporting both shell commands and AI-powered tasks, all accessible via the MCP protocol.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Schedule shell command or prompt to AI tasks using cron expressions
|
|
8
|
+
- AI can have access to MCP servers
|
|
9
|
+
- [Manage tasks](#available-mcp-tools) via MCP protocol
|
|
10
|
+
- Task execution with command output capture
|
|
11
|
+
- Task persistence across restarts (SQLite)
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
### npm (recommended)
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx -y mcp-cron
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
#### Claude Code
|
|
22
|
+
```bash
|
|
23
|
+
claude mcp add mcp-cron -- npx -y mcp-cron
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
#### Cursor / Claude Desktop
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"mcpServers": {
|
|
30
|
+
"mcp-cron": {
|
|
31
|
+
"command": "npx",
|
|
32
|
+
"args": ["-y", "mcp-cron", "--transport", "stdio"]
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Building from Source
|
|
39
|
+
|
|
40
|
+
#### Prerequisites
|
|
41
|
+
- Go 1.24.0 or higher
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Clone the repository
|
|
45
|
+
git clone https://github.com/jolks/mcp-cron.git
|
|
46
|
+
cd mcp-cron
|
|
47
|
+
|
|
48
|
+
# Build the application as mcp-cron binary
|
|
49
|
+
go build -o mcp-cron cmd/mcp-cron/main.go
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Usage
|
|
53
|
+
The server supports two transport modes:
|
|
54
|
+
- **SSE (Server-Sent Events)**: Default HTTP-based transport for browser and network clients
|
|
55
|
+
- **stdio**: Standard input/output transport for direct piping and inter-process communication
|
|
56
|
+
|
|
57
|
+
| Client | Config File Location |
|
|
58
|
+
|--------|----------------------|
|
|
59
|
+
| Cursor | `~/.cursor/mcp.json` |
|
|
60
|
+
| Claude Desktop (Mac) | `~/Library/Application Support/Claude/claude_desktop_config.json`|
|
|
61
|
+
| Claude Desktop (Windows) | `%APPDATA%\Claude\claude_desktop_config.json` |
|
|
62
|
+
|
|
63
|
+
### SSE
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Start the server with HTTP SSE transport (default mode)
|
|
67
|
+
# Default to localhost:8080
|
|
68
|
+
./mcp-cron
|
|
69
|
+
|
|
70
|
+
# Start with custom address and port
|
|
71
|
+
./mcp-cron --address 127.0.0.1 --port 9090
|
|
72
|
+
```
|
|
73
|
+
Config file example
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"mcpServers": {
|
|
77
|
+
"mcp-cron": {
|
|
78
|
+
"url": "http://localhost:8080/sse"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### stdio
|
|
85
|
+
The stdio transport is particularly useful for:
|
|
86
|
+
- Direct piping to/from other processes
|
|
87
|
+
- Integration with CLI tools
|
|
88
|
+
- Testing in environments without HTTP
|
|
89
|
+
- Docker container integration
|
|
90
|
+
|
|
91
|
+
Upon starting Cursor IDE and Claude Desktop, it will **automatically** start the server
|
|
92
|
+
|
|
93
|
+
Config file example
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"mcpServers": {
|
|
97
|
+
"mcp-cron": {
|
|
98
|
+
"command": "<path to where mcp-cron binary is located>/mcp-cron",
|
|
99
|
+
"args": ["--transport", "stdio"]
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Command Line Arguments
|
|
106
|
+
|
|
107
|
+
The following command line arguments are supported:
|
|
108
|
+
|
|
109
|
+
| Argument | Description | Default |
|
|
110
|
+
|----------|-------------|---------|
|
|
111
|
+
| `--address` | The address to bind the server to | `localhost` |
|
|
112
|
+
| `--port` | The port to bind the server to | `8080` |
|
|
113
|
+
| `--transport` | Transport mode: `sse` or `stdio` | `sse` |
|
|
114
|
+
| `--log-level` | Logging level: `debug`, `info`, `warn`, `error`, `fatal` | `info` |
|
|
115
|
+
| `--log-file` | Log file path | stdout |
|
|
116
|
+
| `--version` | Show version information and exit | `false` |
|
|
117
|
+
| `--ai-provider` | AI provider: `openai` or `anthropic` | `openai` |
|
|
118
|
+
| `--ai-base-url` | Custom base URL for OpenAI-compatible endpoints (e.g. Ollama, vLLM, Groq, LiteLLM) | Not set |
|
|
119
|
+
| `--ai-model` | AI model to use for AI tasks | `gpt-4o` |
|
|
120
|
+
| `--ai-max-iterations` | Maximum iterations for tool-enabled AI tasks | `20` |
|
|
121
|
+
| `--mcp-config-path` | Path to MCP configuration file | `~/.cursor/mcp.json` |
|
|
122
|
+
| `--db-path` | Path to SQLite database for result history | `~/.mcp-cron/results.db` |
|
|
123
|
+
|
|
124
|
+
### Environment Variables
|
|
125
|
+
|
|
126
|
+
The following environment variables are supported:
|
|
127
|
+
|
|
128
|
+
| Environment Variable | Description | Default |
|
|
129
|
+
|----------------------|-------------|---------|
|
|
130
|
+
| `MCP_CRON_SERVER_ADDRESS` | The address to bind the server to | `localhost` |
|
|
131
|
+
| `MCP_CRON_SERVER_PORT` | The port to bind the server to | `8080` |
|
|
132
|
+
| `MCP_CRON_SERVER_TRANSPORT` | Transport mode: `sse` or `stdio` | `sse` |
|
|
133
|
+
| `MCP_CRON_SERVER_NAME` | Server name | `mcp-cron` |
|
|
134
|
+
| `MCP_CRON_SERVER_VERSION` | Server version | `0.1.0` |
|
|
135
|
+
| `MCP_CRON_SCHEDULER_DEFAULT_TIMEOUT` | Default timeout for task execution | `10m` |
|
|
136
|
+
| `MCP_CRON_LOGGING_LEVEL` | Logging level: `debug`, `info`, `warn`, `error`, `fatal` | `info` |
|
|
137
|
+
| `MCP_CRON_LOGGING_FILE` | Log file path | stdout |
|
|
138
|
+
| `MCP_CRON_AI_PROVIDER` | AI provider: `openai` or `anthropic` | `openai` |
|
|
139
|
+
| `MCP_CRON_AI_BASE_URL` | Custom base URL for OpenAI-compatible endpoints (e.g. Ollama, vLLM, Groq, LiteLLM) | Not set |
|
|
140
|
+
| `MCP_CRON_AI_API_KEY` | Generic fallback API key (used when provider-specific key is not set) | Not set |
|
|
141
|
+
| `OPENAI_API_KEY` | OpenAI API key for AI tasks | Not set |
|
|
142
|
+
| `ANTHROPIC_API_KEY` | Anthropic API key for AI tasks | Not set |
|
|
143
|
+
| `MCP_CRON_ENABLE_OPENAI_TESTS` | Enable OpenAI integration tests | `false` |
|
|
144
|
+
| `MCP_CRON_AI_MODEL` | LLM model to use for AI tasks | `gpt-4o` |
|
|
145
|
+
| `MCP_CRON_AI_MAX_TOOL_ITERATIONS` | Maximum iterations for tool-enabled tasks | `20` |
|
|
146
|
+
| `MCP_CRON_MCP_CONFIG_FILE_PATH` | Path to MCP configuration file | `~/.cursor/mcp.json` |
|
|
147
|
+
| `MCP_CRON_STORE_DB_PATH` | Path to SQLite database for result history | `~/.mcp-cron/results.db` |
|
|
148
|
+
|
|
149
|
+
### Logging
|
|
150
|
+
|
|
151
|
+
When running with the default SSE transport, logs are output to the console.
|
|
152
|
+
|
|
153
|
+
When running with stdio transport, logs are redirected to a `mcp-cron.log` log file to prevent interference with the JSON-RPC protocol:
|
|
154
|
+
- Log file location: Same location as `mcp-cron` binary.
|
|
155
|
+
- Task outputs, execution details, and server diagnostics are written to this file.
|
|
156
|
+
- The stdout/stderr streams are kept clean for protocol messages only.
|
|
157
|
+
|
|
158
|
+
### Available MCP Tools
|
|
159
|
+
|
|
160
|
+
The server exposes several tools through the MCP protocol:
|
|
161
|
+
|
|
162
|
+
1. `list_tasks` - Lists all scheduled tasks
|
|
163
|
+
2. `get_task` - Gets a specific task by ID
|
|
164
|
+
3. `add_task` - Adds a new scheduled task
|
|
165
|
+
4. `add_ai_task` - Adds a new scheduled AI (LLM) task with a prompt
|
|
166
|
+
5. `update_task` - Updates an existing task
|
|
167
|
+
6. `remove_task` - Removes a task by ID
|
|
168
|
+
7. `enable_task` - Enables a disabled task
|
|
169
|
+
8. `disable_task` - Disables an enabled task
|
|
170
|
+
9. `get_task_result` - Gets execution results for a task (latest by default, or recent history with `limit`)
|
|
171
|
+
|
|
172
|
+
### Task Format
|
|
173
|
+
|
|
174
|
+
Tasks have the following structure:
|
|
175
|
+
|
|
176
|
+
```json
|
|
177
|
+
{
|
|
178
|
+
"id": "task_1234567890",
|
|
179
|
+
"name": "Example Task",
|
|
180
|
+
"schedule": "0 */5 * * * *",
|
|
181
|
+
"command": "echo 'Task executed!'",
|
|
182
|
+
"prompt": "Analyze yesterday's sales data and provide a summary",
|
|
183
|
+
"type": "shell_command",
|
|
184
|
+
"description": "An example task that runs every 5 minutes",
|
|
185
|
+
"enabled": true,
|
|
186
|
+
"lastRun": "2025-01-01T12:00:00Z",
|
|
187
|
+
"nextRun": "2025-01-01T12:05:00Z",
|
|
188
|
+
"status": "completed",
|
|
189
|
+
"createdAt": "2025-01-01T00:00:00Z",
|
|
190
|
+
"updatedAt": "2025-01-01T12:00:00Z"
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
For shell command tasks, use the `command` field to specify the command to execute.
|
|
195
|
+
For AI tasks, use the `prompt` field to specify what the AI should do.
|
|
196
|
+
The `type` field can be either `shell_command` (default) or `AI`.
|
|
197
|
+
|
|
198
|
+
### Task Status
|
|
199
|
+
|
|
200
|
+
The tasks can have the following status values:
|
|
201
|
+
- `pending` - Task has not been run yet
|
|
202
|
+
- `running` - Task is currently running
|
|
203
|
+
- `completed` - Task has successfully completed
|
|
204
|
+
- `failed` - Task has failed during execution
|
|
205
|
+
- `disabled` - Task is disabled and won't run on schedule
|
|
206
|
+
|
|
207
|
+
### Cron Expression Format
|
|
208
|
+
|
|
209
|
+
The scheduler uses the [github.com/robfig/cron/v3](https://github.com/robfig/cron) library for parsing cron expressions. The format includes seconds:
|
|
210
|
+
|
|
211
|
+
```
|
|
212
|
+
┌───────────── second (0 - 59) (Optional)
|
|
213
|
+
│ ┌───────────── minute (0 - 59)
|
|
214
|
+
│ │ ┌───────────── hour (0 - 23)
|
|
215
|
+
│ │ │ ┌───────────── day of the month (1 - 31)
|
|
216
|
+
│ │ │ │ ┌───────────── month (1 - 12)
|
|
217
|
+
│ │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday)
|
|
218
|
+
│ │ │ │ │ │
|
|
219
|
+
│ │ │ │ │ │
|
|
220
|
+
* * * * * *
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Examples:
|
|
224
|
+
- `0 */5 * * * *` - Every 5 minutes (at 0 seconds)
|
|
225
|
+
- `0 0 * * * *` - Every hour
|
|
226
|
+
- `0 0 0 * * *` - Every day at midnight
|
|
227
|
+
- `0 0 12 * * MON-FRI` - Every weekday at noon
|
|
228
|
+
|
|
229
|
+
## Development
|
|
230
|
+
|
|
231
|
+
### Project Structure
|
|
232
|
+
|
|
233
|
+
```
|
|
234
|
+
mcp-cron/
|
|
235
|
+
├── cmd/
|
|
236
|
+
│ └── mcp-cron/ # Main application entry point
|
|
237
|
+
├── internal/
|
|
238
|
+
│ ├── agent/ # AI agent execution functionality
|
|
239
|
+
│ ├── command/ # Command execution functionality
|
|
240
|
+
│ ├── config/ # Configuration handling
|
|
241
|
+
│ ├── errors/ # Error types and handling
|
|
242
|
+
│ ├── logging/ # Logging utilities
|
|
243
|
+
│ ├── model/ # Data models and types
|
|
244
|
+
│ ├── scheduler/ # Task scheduling
|
|
245
|
+
│ ├── server/ # MCP server implementation
|
|
246
|
+
│ ├── store/ # SQLite store (persistent task definitions + result history)
|
|
247
|
+
│ └── utils/ # Miscellanous utilities
|
|
248
|
+
├── npm/ # npm packages (main + platform-specific binaries)
|
|
249
|
+
├── scripts/ # Build and publish scripts
|
|
250
|
+
├── go.mod # Go modules definition
|
|
251
|
+
├── go.sum # Go modules checksums
|
|
252
|
+
└── README.md # Project documentation
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Building and Testing
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
# Build the application
|
|
259
|
+
go build -o mcp-cron cmd/mcp-cron/main.go
|
|
260
|
+
|
|
261
|
+
# Run tests
|
|
262
|
+
go test ./...
|
|
263
|
+
|
|
264
|
+
# Run tests and check coverage
|
|
265
|
+
go test ./... -cover
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
## Acknowledgments
|
|
269
|
+
|
|
270
|
+
- [modelcontextprotocol/go-sdk](https://github.com/modelcontextprotocol/go-sdk) - Official Go SDK for the Model Context Protocol
|
|
271
|
+
- [robfig/cron](https://github.com/robfig/cron) - Cron library for Go
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-cron",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "MCP server for cron task scheduling (shell commands and AI prompts)",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"bin": {
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
"url": "git+https://github.com/jolks/mcp-cron.git"
|
|
12
12
|
},
|
|
13
13
|
"optionalDependencies": {
|
|
14
|
-
"mcp-cron-darwin-amd64": "0.1.
|
|
15
|
-
"mcp-cron-darwin-arm64": "0.1.
|
|
16
|
-
"mcp-cron-linux-amd64": "0.1.
|
|
17
|
-
"mcp-cron-linux-arm64": "0.1.
|
|
18
|
-
"mcp-cron-windows-amd64": "0.1.
|
|
19
|
-
"mcp-cron-windows-arm64": "0.1.
|
|
14
|
+
"mcp-cron-darwin-amd64": "0.1.1",
|
|
15
|
+
"mcp-cron-darwin-arm64": "0.1.1",
|
|
16
|
+
"mcp-cron-linux-amd64": "0.1.1",
|
|
17
|
+
"mcp-cron-linux-arm64": "0.1.1",
|
|
18
|
+
"mcp-cron-windows-amd64": "0.1.1",
|
|
19
|
+
"mcp-cron-windows-arm64": "0.1.1"
|
|
20
20
|
}
|
|
21
21
|
}
|