@patrick-rodgers/cron-claude 0.1.0 → 0.1.2
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/.claude-plugin/plugin.json +27 -0
- package/.mcp.json +8 -0
- package/CLAUDE.md +321 -0
- package/README.md +440 -401
- package/commands/cron-list.md +21 -0
- package/commands/cron-run.md +18 -0
- package/commands/cron-status.md +20 -0
- package/dist/cli.js +55 -57
- package/dist/cli.js.map +1 -1
- package/dist/config.js +15 -20
- package/dist/config.js.map +1 -1
- package/dist/executor.js +36 -44
- package/dist/executor.js.map +1 -1
- package/dist/index.js +6 -22
- package/dist/index.js.map +1 -1
- package/dist/logger.js +33 -46
- package/dist/logger.js.map +1 -1
- package/dist/mcp-server.js +80 -79
- package/dist/mcp-server.js.map +1 -1
- package/dist/notifier.js +5 -13
- package/dist/notifier.js.map +1 -1
- package/dist/scheduler.js +57 -69
- package/dist/scheduler.js.map +1 -1
- package/dist/types.js +1 -2
- package/dist/types.js.map +1 -1
- package/hooks/hooks.json +5 -0
- package/hooks/session-start.sh +23 -0
- package/package.json +70 -52
- package/skills/cron/SKILL.md +187 -0
- package/tasks/example-daily-summary.md +37 -0
- package/tasks/example-weekly-backup.md +27 -0
- package/install.ps1 +0 -93
- package/uninstall.ps1 +0 -59
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cron-claude",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Scheduled Claude task execution - MCP server for automating recurring tasks via cron schedules",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Patrick Rodgers"
|
|
7
|
+
},
|
|
8
|
+
"repository": "https://github.com/patrick-rodgers/cron-claude",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"permissions": {
|
|
11
|
+
"mcp": {
|
|
12
|
+
"cron-claude": [
|
|
13
|
+
"cron_create_task",
|
|
14
|
+
"cron_register_task",
|
|
15
|
+
"cron_unregister_task",
|
|
16
|
+
"cron_list_tasks",
|
|
17
|
+
"cron_enable_task",
|
|
18
|
+
"cron_disable_task",
|
|
19
|
+
"cron_run_task",
|
|
20
|
+
"cron_view_logs",
|
|
21
|
+
"cron_verify_log",
|
|
22
|
+
"cron_status",
|
|
23
|
+
"cron_get_task"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
package/.mcp.json
ADDED
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
**Cron-Claude** - An MCP (Model Context Protocol) server that enables scheduled, automated execution of Claude tasks using Windows Task Scheduler. Define tasks in markdown files, schedule them with cron expressions, and let Claude run them automatically.
|
|
8
|
+
|
|
9
|
+
**Key Features:**
|
|
10
|
+
- 11 MCP tools for complete task lifecycle management
|
|
11
|
+
- Windows Task Scheduler integration for reliable execution
|
|
12
|
+
- CLI and API invocation modes
|
|
13
|
+
- Cryptographic audit logging with HMAC-SHA256 signatures
|
|
14
|
+
- Windows toast notifications
|
|
15
|
+
- Automatic log storage via memory integration
|
|
16
|
+
|
|
17
|
+
## Build & Development Commands
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install # Install dependencies
|
|
21
|
+
npm run build # Compile TypeScript (tsc) to dist/
|
|
22
|
+
npm run dev # Watch mode (tsc --watch)
|
|
23
|
+
npm run mcp # Run MCP server directly (for testing)
|
|
24
|
+
npm run prepack # Build before publishing
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Architecture
|
|
28
|
+
|
|
29
|
+
**TypeScript ESM project** with NodeNext module resolution. Source in `src/`, compiles to `dist/`.
|
|
30
|
+
|
|
31
|
+
### MCP Server Entry Point
|
|
32
|
+
|
|
33
|
+
- **`src/mcp-server.ts`** → **`dist/mcp-server.js`** - Primary entry point
|
|
34
|
+
- Registered as `cron-claude-mcp` binary in package.json
|
|
35
|
+
- Uses `@modelcontextprotocol/sdk` with stdio transport
|
|
36
|
+
- Exposes 11 tools for task management
|
|
37
|
+
- Never uses `console.log()` (stdio protocol constraint), only `console.error()` for logging
|
|
38
|
+
|
|
39
|
+
### Source Module Responsibilities
|
|
40
|
+
|
|
41
|
+
#### Core Modules
|
|
42
|
+
|
|
43
|
+
- **`mcp-server.ts`** - MCP server implementation
|
|
44
|
+
- Server initialization and transport setup
|
|
45
|
+
- Tool registration (11 tools)
|
|
46
|
+
- Request handlers for all cron operations
|
|
47
|
+
- Task file management
|
|
48
|
+
|
|
49
|
+
- **`scheduler.ts`** - Windows Task Scheduler integration
|
|
50
|
+
- Register/unregister tasks with Task Scheduler
|
|
51
|
+
- Enable/disable tasks
|
|
52
|
+
- Query task status and next run times
|
|
53
|
+
- Uses PowerShell commands via Node.js `execSync`
|
|
54
|
+
|
|
55
|
+
- **`executor.ts`** - Task execution engine
|
|
56
|
+
- Reads task definitions from markdown files
|
|
57
|
+
- Executes via CLI (`claude-code`) or API (Anthropic API)
|
|
58
|
+
- Manages execution lifecycle
|
|
59
|
+
- Integrates with logger and notifier
|
|
60
|
+
|
|
61
|
+
- **`logger.ts`** - Audit logging with cryptographic signatures
|
|
62
|
+
- HMAC-SHA256 signing of all log entries
|
|
63
|
+
- Stores logs via memory integration (odsp-memory)
|
|
64
|
+
- Fallback to local `./logs/` directory
|
|
65
|
+
- Log verification functionality
|
|
66
|
+
|
|
67
|
+
- **`notifier.ts`** - Windows toast notifications
|
|
68
|
+
- Shows completion notifications
|
|
69
|
+
- Uses `node-notifier` package
|
|
70
|
+
- Configurable per-task
|
|
71
|
+
|
|
72
|
+
- **`config.ts`** - Configuration management
|
|
73
|
+
- Loads/saves config from `~/.cron-claude/config.json`
|
|
74
|
+
- Manages secret key for HMAC signing
|
|
75
|
+
- Auto-generates key on first use
|
|
76
|
+
|
|
77
|
+
- **`types.ts`** - Shared TypeScript types
|
|
78
|
+
- `TaskDefinition`, `TaskMetadata`, `ExecutionLog`
|
|
79
|
+
- `Config`, `NotificationOptions`
|
|
80
|
+
|
|
81
|
+
### Data Flow
|
|
82
|
+
|
|
83
|
+
1. **Task Storage**: `tasks/*.md` - Markdown files with YAML frontmatter
|
|
84
|
+
2. **Execution**: Task Scheduler → PowerShell → Node.js → `executeTask()`
|
|
85
|
+
3. **Logging**: Execution results → Logger → Memory integration or local files
|
|
86
|
+
4. **Notifications**: Completion → Notifier → Windows Toast
|
|
87
|
+
|
|
88
|
+
### Task Definition Format
|
|
89
|
+
|
|
90
|
+
```markdown
|
|
91
|
+
---
|
|
92
|
+
id: my-task
|
|
93
|
+
schedule: "0 9 * * *"
|
|
94
|
+
invocation: cli
|
|
95
|
+
notifications:
|
|
96
|
+
toast: true
|
|
97
|
+
enabled: true
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
# Task Instructions
|
|
101
|
+
|
|
102
|
+
Instructions for Claude in markdown format...
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Dependencies
|
|
106
|
+
|
|
107
|
+
- **`@modelcontextprotocol/sdk`** - MCP protocol implementation
|
|
108
|
+
- **`gray-matter`** - YAML frontmatter parsing
|
|
109
|
+
- **`node-cron`** - Cron expression validation
|
|
110
|
+
- **`node-notifier`** - Windows toast notifications
|
|
111
|
+
- **`commander`** - CLI parsing (if needed)
|
|
112
|
+
|
|
113
|
+
## MCP Interface
|
|
114
|
+
|
|
115
|
+
### Tools (11 total)
|
|
116
|
+
|
|
117
|
+
**Task Management (6):**
|
|
118
|
+
1. `cron_create_task` - Create new task from template
|
|
119
|
+
2. `cron_register_task` - Register with Task Scheduler
|
|
120
|
+
3. `cron_unregister_task` - Remove from scheduler
|
|
121
|
+
4. `cron_enable_task` - Enable task
|
|
122
|
+
5. `cron_disable_task` - Disable task
|
|
123
|
+
6. `cron_get_task` - Get full task definition
|
|
124
|
+
|
|
125
|
+
**Execution & Monitoring (3):**
|
|
126
|
+
7. `cron_run_task` - Execute immediately
|
|
127
|
+
8. `cron_list_tasks` - List all tasks with status
|
|
128
|
+
9. `cron_view_logs` - View execution logs
|
|
129
|
+
|
|
130
|
+
**Verification & Status (2):**
|
|
131
|
+
10. `cron_verify_log` - Verify log HMAC signature
|
|
132
|
+
11. `cron_status` - System status and configuration
|
|
133
|
+
|
|
134
|
+
## Plugin Structure
|
|
135
|
+
|
|
136
|
+
This project is a Claude Code plugin (installed via `claude plugin add`):
|
|
137
|
+
|
|
138
|
+
- **`.claude-plugin/plugin.json`** - Plugin manifest with metadata
|
|
139
|
+
- **`.mcp.json`** - MCP server configuration (npx invocation)
|
|
140
|
+
- **`CLAUDE.md`** - This file (project documentation)
|
|
141
|
+
- **`skills/cron/SKILL.md`** - Skill documentation and usage
|
|
142
|
+
- **`commands/`** - Slash commands (`/cron-status`, `/cron-list`, `/cron-run`)
|
|
143
|
+
- **`hooks/`** - Event hooks (SessionStart for startup message)
|
|
144
|
+
- **`tasks/`** - Task definition files (*.md)
|
|
145
|
+
|
|
146
|
+
### SessionStart Hook Behavior
|
|
147
|
+
|
|
148
|
+
When a new session starts, the `hooks/session-start.sh` hook displays:
|
|
149
|
+
1. Welcome message about Cron-Claude availability
|
|
150
|
+
2. Quick command reference
|
|
151
|
+
3. Available tools list
|
|
152
|
+
|
|
153
|
+
This helps users discover cron functionality in new sessions.
|
|
154
|
+
|
|
155
|
+
## Task Categories & Use Cases
|
|
156
|
+
|
|
157
|
+
**Common Task Types:**
|
|
158
|
+
- **Daily summaries** - Morning briefings, calendar reviews
|
|
159
|
+
- **Weekly reports** - Aggregated metrics, status updates
|
|
160
|
+
- **Hourly monitors** - Health checks, status monitoring
|
|
161
|
+
- **Backups** - Periodic data archiving
|
|
162
|
+
- **Reminders** - Scheduled notifications
|
|
163
|
+
|
|
164
|
+
## Invocation Methods
|
|
165
|
+
|
|
166
|
+
**CLI Mode** (`invocation: cli`)
|
|
167
|
+
- Executes: `claude-code --file <task-file>`
|
|
168
|
+
- Full Claude environment with all tools
|
|
169
|
+
- Best for: Complex tasks requiring multiple tools
|
|
170
|
+
- Requires: Claude CLI installed and in PATH
|
|
171
|
+
|
|
172
|
+
**API Mode** (`invocation: api`)
|
|
173
|
+
- Direct Anthropic API calls
|
|
174
|
+
- Best for: Simple, contained tasks
|
|
175
|
+
- Requires: `ANTHROPIC_API_KEY` environment variable
|
|
176
|
+
- Note: May incur API costs
|
|
177
|
+
|
|
178
|
+
## Audit Logging & Security
|
|
179
|
+
|
|
180
|
+
**Log Structure:**
|
|
181
|
+
```markdown
|
|
182
|
+
---
|
|
183
|
+
taskId: task-id
|
|
184
|
+
executionId: uuid
|
|
185
|
+
timestamp: 2024-02-14T10:30:00Z
|
|
186
|
+
status: success|failure
|
|
187
|
+
signature: hmac-sha256-hex
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
# Execution Log
|
|
191
|
+
|
|
192
|
+
Log content...
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**Signature Verification:**
|
|
196
|
+
- Uses secret key from `~/.cron-claude/config.json`
|
|
197
|
+
- HMAC-SHA256 of log content (excluding signature field)
|
|
198
|
+
- Verifiable with `cron_verify_log` tool
|
|
199
|
+
|
|
200
|
+
## Conventions
|
|
201
|
+
|
|
202
|
+
- All imports use `.js` extensions (ESM requirement with NodeNext)
|
|
203
|
+
- MCP server logs to stderr only (stdio protocol requirement)
|
|
204
|
+
- Tasks stored as `tasks/<task-id>.md`
|
|
205
|
+
- Windows Task Scheduler names: `CronClaude_<task-id>`
|
|
206
|
+
- Logs stored via odsp-memory with category `cron-task`
|
|
207
|
+
|
|
208
|
+
## Testing
|
|
209
|
+
|
|
210
|
+
**Manual Testing:**
|
|
211
|
+
```bash
|
|
212
|
+
npm run build
|
|
213
|
+
npm run mcp # Run server directly
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Then in another terminal, use the MCP Inspector:
|
|
217
|
+
```bash
|
|
218
|
+
npx @modelcontextprotocol/inspector node dist/mcp-server.js
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
**Integration Testing:**
|
|
222
|
+
1. Install plugin: `claude plugin add <path>`
|
|
223
|
+
2. Test tools via Claude Code
|
|
224
|
+
3. Verify Task Scheduler registration
|
|
225
|
+
4. Run task manually and check logs
|
|
226
|
+
|
|
227
|
+
## Configuration
|
|
228
|
+
|
|
229
|
+
**User Config Location:** `~/.cron-claude/config.json`
|
|
230
|
+
|
|
231
|
+
```json
|
|
232
|
+
{
|
|
233
|
+
"secretKey": "base64-encoded-key"
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
Generated automatically on first use.
|
|
238
|
+
|
|
239
|
+
## Windows Task Scheduler Integration
|
|
240
|
+
|
|
241
|
+
**PowerShell Commands Used:**
|
|
242
|
+
- `Register-ScheduledTask` - Create task
|
|
243
|
+
- `Unregister-ScheduledTask` - Remove task
|
|
244
|
+
- `Enable-ScheduledTask` - Enable
|
|
245
|
+
- `Disable-ScheduledTask` - Disable
|
|
246
|
+
- `Get-ScheduledTask` - Query status
|
|
247
|
+
|
|
248
|
+
**Task Configuration:**
|
|
249
|
+
- Trigger: Cron schedule converted to Task Scheduler trigger
|
|
250
|
+
- Action: `node dist/mcp-server.js` (or similar execution path)
|
|
251
|
+
- Principal: Current user
|
|
252
|
+
- Settings: Allow on-demand execution, don't start if on batteries (optional)
|
|
253
|
+
|
|
254
|
+
## Error Handling
|
|
255
|
+
|
|
256
|
+
All tools return structured MCP responses:
|
|
257
|
+
```typescript
|
|
258
|
+
{
|
|
259
|
+
content: [{ type: 'text', text: 'Success or error message' }],
|
|
260
|
+
isError: boolean
|
|
261
|
+
}
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Errors are surfaced to Claude with clear, actionable messages.
|
|
265
|
+
|
|
266
|
+
## Requirements
|
|
267
|
+
|
|
268
|
+
- **OS:** Windows 10/11 (uses Windows Task Scheduler)
|
|
269
|
+
- **Node.js:** >= 18.0.0
|
|
270
|
+
- **Claude Code:** With MCP support
|
|
271
|
+
- **Claude CLI:** For CLI invocation mode (optional)
|
|
272
|
+
- **Anthropic API Key:** For API invocation mode (optional)
|
|
273
|
+
|
|
274
|
+
## Installation for Users
|
|
275
|
+
|
|
276
|
+
**Via Claude Code (recommended):**
|
|
277
|
+
```bash
|
|
278
|
+
claude plugin add @patrick-rodgers/cron-claude
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
**Via npm + manual configuration:**
|
|
282
|
+
```bash
|
|
283
|
+
npm install -g @patrick-rodgers/cron-claude
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
Then add to `~/.claude/config.json`:
|
|
287
|
+
```json
|
|
288
|
+
{
|
|
289
|
+
"mcpServers": {
|
|
290
|
+
"cron-claude": {
|
|
291
|
+
"command": "npx",
|
|
292
|
+
"args": ["@patrick-rodgers/cron-claude"]
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
## Publishing
|
|
299
|
+
|
|
300
|
+
Before publishing to npm:
|
|
301
|
+
1. Update version in `package.json` and `.claude-plugin/plugin.json`
|
|
302
|
+
2. Run `npm run build` to compile
|
|
303
|
+
3. Test locally with `npm link`
|
|
304
|
+
4. Publish: `npm publish --access public`
|
|
305
|
+
|
|
306
|
+
## Troubleshooting
|
|
307
|
+
|
|
308
|
+
**Task not executing:**
|
|
309
|
+
- Check Task Scheduler for `CronClaude_<task-id>`
|
|
310
|
+
- Verify task is enabled in both file and scheduler
|
|
311
|
+
- Check Windows Event Viewer for Task Scheduler errors
|
|
312
|
+
|
|
313
|
+
**Logs not appearing:**
|
|
314
|
+
- Verify odsp-memory integration is working
|
|
315
|
+
- Check fallback `./logs/` directory
|
|
316
|
+
- Ensure permissions on log directories
|
|
317
|
+
|
|
318
|
+
**Toast notifications not showing:**
|
|
319
|
+
- Check Windows notification settings
|
|
320
|
+
- Verify `notifications.toast: true` in task file
|
|
321
|
+
- Disable Focus Assist temporarily
|