日历与提醒服务器

通过EventKit为Apple日历和提醒事项提供MCP服务器,使用SSE传输公开日历和提醒数据。

  • by gellyfish-ai
  • Swift
  • 本地部署
  • 更新于
在 GitHub 查看 gellyfish-ai/mcp-calendar

使用说明

mcp日历

通过EventKit为Apple日历和提醒提供MCP服务器。使用SSE传输通过模型上下文协议(MCP)公开日历和提醒数据。

需求

  • macOS 14+(索诺玛或更高版本)
  • Swift 6.0+
  • Xcode 16+(或Swift工具链)

设置

1.建造

swift build

2.授予权限

EventKit需要TCC(透明度、同意和控制)权限。从终端运行安装命令以触发权限对话框:

swift run mcp-calendar --setup

这会触发初始TCC请求。 提示可能不会出现 --特别是如果通过SSH或后台进程运行。

授予权限的可靠方法:

  1. 跑 --setup 一次(可能会也可能不会显示提示)
  2. 首选 系统设置→ 隐私和安全→ 日历 → find mcp-calendar → 打开开关
  3. 首选 系统设置→ 隐私和安全→ 提醒事项 → find mcp-calendar → 打开开关

关键: 不要依赖从iTerm或SSH运行来授予权限。TCC为每个二进制文件授予权限——从iTerm授予iTerm,而不是mcp日历。始终在“系统设置”中进行验证和切换。

如果你重建 二进制文件,macOS可能会撤销权限——在系统设置中重新授予。

验证TCC状态:

sqlite3 ~/Library/Application\ Support/com.apple.TCC/TCC.db \
  "SELECT client, auth_value FROM access WHERE service = 'kTCCServiceCalendar'"
# auth_value: 0 = denied, 2 = granted

3.跑步

swift run mcp-calendar

服务器启动于 http://127.0.0.1:8201 默认情况下。

4.作为launchd守护进程安装(推荐)

作为一个持久的macOS守护进程运行,在启动时启动,在崩溃时重新启动:

cat > ~/Library/LaunchAgents/com.gellyfish.mcp-calendar.plist << 'PLIST'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.gellyfish.mcp-calendar</string>
    <key>ProgramArguments</key>
    <array>
        <string>~/.local/bin/mcp-calendar</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
    <key>StandardOutPath</key>
    <string>~/Library/Logs/mcp-calendar.log</string>
    <key>StandardErrorPath</key>
    <string>~/Library/Logs/mcp-calendar.log</string>
</dict>
</plist>
PLIST

# Load the daemon
launchctl load ~/Library/LaunchAgents/com.gellyfish.mcp-calendar.plist

# Verify it's running
curl -s http://localhost:8201/health

管理守护进程:

# Stop
launchctl unload ~/Library/LaunchAgents/com.gellyfish.mcp-calendar.plist

# Restart (unload + load)
launchctl unload ~/Library/LaunchAgents/com.gellyfish.mcp-calendar.plist
launchctl load ~/Library/LaunchAgents/com.gellyfish.mcp-calendar.plist

# Check logs
tail -f ~/Library/Logs/mcp-calendar.log

5.在Gellyfish网关注册

INSERT INTO mcp_servers (id, name, type, command, args, env)
VALUES ('<uuid>', 'calendar', 'available', 'npx',
  '["-y", "mcp-remote", "http://localhost:8201/sse", "--allow-http"]', '{}');

然后通过分配给需要它的配置文件 profile_mcps.

配置

环境变量:

变量 默认值 描述
HOST 127.0.0.1 绑定地址
PORT 8201 监听端口

MCP传输

使用传统的HTTP+SSE传输:

  • SSE端点: GET /sse -连接以接收服务器事件
  • 消息端点: POST /message?sessionId=<id> -发送JSON-RPC消息
  • 健康检查: GET /health

工具

工具 说明
list_calendars 列出所有可用日历
list_events 列出日期范围内的事件
create_event 创建日历事件
list_reminder_lists 列出所有提醒列表
create_reminder_list 创建新的提醒列表
list_reminders 列表提醒(可选按列表筛选)
create_reminder 创建带有可选截止日期的提醒
complete_reminder 将提醒标记为完成
update_reminder 更新现有提醒(标题、截止日期、注释、优先级、完成、列表)
delete_reminder 删除提醒

码头工人

Dockerfile和docker-compose.yml被包括在内以供参考,但 EventKit要求macOS具有TCC权限Docker构建将编译Linux的二进制文件,但它无法访问日历/提醒数据。对于生产使用,请在macOS上本机运行二进制文件。

安全

  • 绑定到 127.0.0.1 默认情况下(仅限本地主机)
  • 响应中没有凭据或令牌
  • 设计为以管理员用户身份运行,网关通过HTTP连接
  • 根据MCP-SECURITY.md:个人数据类别MCP

许可证

麻省理工学院