Token导航 LogoToken导航TokenDH.com
Claude Cron logo
开发工具未说明官方级别未说明来源级核验

Claude Cron

MCP Server

一个为AI编程助手设计的后台任务调度系统,支持定时执行shell命令、AI提示和通知提醒,适用于自动化测试、定期监控等场景。

工具数

5

提示词数

0

GitHub Stars

0

资源数

0
TypeScriptClaude开发工具Claude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

frr149

提供方

frr149

最后核验

2026/5/17 20:22

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

克劳德·克伦

![License: MIT](LICENSE) ![Bun](https://bun.sh) ![TypeScript](https://www.typescriptlang.org)

AI编码助手的任务被推迟。MCP服务器+守护进程,允许任何AI编码助手为未来安排任务。

这与 /loop? 已添加克劳德代码2.1.71 /loop 用于会话中的重复任务。它非常适合短暂的监控,但当你关闭终端时就会死亡。claude cron作为操作系统守护进程运行——您的任务在重启后仍能存活,并在您睡眠时执行。 阅读完整的比较.

快速入门

bun install
bun test          # 38 tests
bun run typecheck # tsc --noEmit

Claude代码配置

添加 ~/.claude/settings.json:

{
  "mcpServers": {
    "claude-cron": {
      "command": "bun",
      "args": ["run", "/Users/fernando/code/claude-cron/src/index.ts"],
      "env": {
        "CLAUDE_CRON_DB": "/Users/fernando/.claude/claude-cron.sqlite",
        "GMAIL_ADDRESS": "frr@keepcoding.io",
        "GMAIL_APP_PASSWORD": "op://FRR DEV/...",
        "NTFY_TOPIC": "claude-cron-frr-xxx",
        "NTFY_URL": "https://ntfy.sh"
      }
    }
  }
}

建筑

AI Assistant (Claude Code / Codex / Copilot)
    │ stdio (MCP protocol)
    ▼
MCP Server (src/index.ts)          ← Task CRUD
    │ SQLite (WAL mode)
    ▼
Runner / Daemon (src/runner.ts)    ← Loop: executes due tasks
    ├─ reminder  → notification + email + push
    ├─ shell     → Bun.spawn(command)
    ├─ claude    → claude -p --output-format text "prompt"
    ├─ codex     → codex --quiet "prompt"
    └─ copilot   → gh copilot suggest "prompt"

MCP工具

工具说明
schedule_task为未来安排任务
list_tasks列出任务(按状态、即将进行、标签筛选)
cancel_task按ID取消任务
run_now标记任务以立即执行
install_daemon将运行者注册为操作系统服务

调度任务

{
  name: "Nightly tests",
  type: "shell",              // reminder | shell | claude | codex | copilot
  when: "daily at 3:00",      // see "When expressions" below
  payload: {
    command: "cd ~/code/bfclaude && make test",  // shell
    // message: "...",         // reminder
    // prompt: "...",          // claude/codex/copilot
    // model: "haiku",
    // workingDir: "/path",
    // maxBudgetUsd: 0.10,
  },
  notify: ["notification", "email", "push"],
  notifyTo: "frr@keepcoding.io",
  tags: ["ci"],
}

when 表达方式

类型示例
自然语言"tomorrow 9:00", "in 30 minutes", "next friday at 3pm"
Cron(5个字段)"0 9 * * 1", "*/5 * * * *"
ISO 8601"2026-03-01T09:00:00Z", "2026-03-01"
快捷方式"every monday at 8", "daily at 9:00", "every 5 minutes"

解析:时间节点(自然)+croner(cron)+正则表达式(快捷方式)。快捷方式在chrono节点之前进行评估,因此“每周一8点”不会被解释为单个日期。

结构

src/
├── index.ts              # MCP server entry point (5 tools)
├── runner.ts             # Daemon: oneshot (launchd) or --loop (dev)
├── queue.ts              # SQLite: schema, CRUD, getDueTasks
├── scheduler.ts          # parseWhen(): chrono-node + croner + shortcuts
├── adapters/
│   ├── types.ts          # AIAdapter interface
│   ├── claude.ts         # claude -p --output-format text
│   ├── codex.ts          # codex --quiet (stub)
│   └── copilot.ts        # gh copilot suggest (stub)
├── notify/
│   ├── types.ts          # NotificationAdapter interface
│   ├── desktop.ts        # node-notifier (cross-platform)
│   ├── email.ts          # Direct SMTP to Gmail (TLS 465)
│   └── push.ts           # ntfy.sh (mobile + Apple Watch)
└── daemon/
    ├── types.ts          # DaemonInstaller interface
    ├── detect.ts         # process.platform → installer
    ├── launchd.ts        # macOS: ~/Library/LaunchAgents/
    ├── systemd.ts        # Linux: ~/.config/systemd/user/
    └── schtasks.ts       # Windows: Task Scheduler

跑者

两种模式:

# Oneshot (for launchd StartInterval / systemd timer)
bun run src/runner.ts

# Continuous loop (for dev or KeepAlive)
bun run src/runner.ts --loop

守护进程每60秒读取一次SQLite(可通过以下方式配置 CLAUDE_CRON_INTERVAL),执行到期任务并发送通知。

Cron任务在完成后会自动重新安排时间(next_run重新计算)。一次性任务过渡到 completedfailed.

守护进程

# Install (from Claude Code via MCP tool install_daemon, or manually):
# macOS:
bun run src/daemon/launchd.ts  # generates plist + launchctl load

# Verify
launchctl list | grep claude-cron
tail -f ~/Library/Logs/claude-cron.log

# Uninstall
launchctl unload ~/Library/LaunchAgents/com.claude-cron.runner.plist

通知

渠道要求环境变量
桌面节点通知器(包括在内)--
电子邮件Gmail应用程序密码GMAIL_ADDRESS, GMAIL_APP_PASSWORD
手机/手表上的推送(ntfy)ntfy应用程序NTFY_TOPIC, NTFY_URL (可选), NTFY_TOKEN (可选)

SQLite架构

tasks (
  id TEXT PRIMARY KEY,          -- nanoid 12 chars
  name, type, status,           -- type: reminder|shell|claude|codex|copilot
  run_at INTEGER,               -- Unix ts (one-off)
  cron TEXT,                    -- Cron expression (recurring)
  payload TEXT,                 -- JSON per type
  notify_via TEXT,              -- JSON array: ["notification","email","push"]
  notify_to TEXT,               -- Destination email
  next_run, last_run,           -- Timestamps
  run_count, last_result,       -- Executions + JSON result
  created_at, created_by, tags  -- Metadata
)

依赖项

  • @modelcontextprotocol/sdk --MCP协议
  • chrono-node --自然语言→ Date
  • croner --Cron解析+下一次运行
  • nanoid --短ID
  • node-notifier --跨平台桌面通知
  • zod --MCP输入验证
  • bun:sqlite --内置,零存款

待办事项

  • \[\]在real settings.json中配置MCP并进行端到端测试
  • \[\]使用安装守护进程 install_daemon 并验证整个周期
  • \[\]设置ntfy以推送到手机/手表
  • \[\]npm发布(名称待定)
  • \[\]在macOS+Linux上进行CI测试
  • \[\]带实际使用GIF的README

目录标签

目录标签

TypeScriptClaude开发工具任务调度本地部署AI编程助手自动化测试后台服务定时任务

支持客户端

Claude

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

5

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明none部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP