谷歌日历MCP服务器

一个用于Google Calendar集成的模型上下文协议(MCP)服务器,支持OAuth2/PKCE认证和安全钥匙链存储。

  • by solo-ist
  • TypeScript
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 solo-ist/gcp

使用说明

谷歌日历MCP服务器

用于Google日历集成的模型上下文协议(MCP)服务器,具有OAuth2/PKCE身份验证和安全的密钥链存储。

包裹

  • @独奏/认证 --OAuth2具有PKCE、操作系统密钥链存储、多帐户支持
  • @独奏/日历mcp --配备谷歌日历工具的MCP服务器

快速开始

1.设置Google Cloud凭据

  1. 首选 Google 云控制台
  2. 创建新项目或选择现有项目
  3. 启用 谷歌日历API
  4. 创建OAuth 2.0凭据(桌面应用程序类型)
  5. 添加 http://127.0.0.1:3000 作为授权重定向URI
  6. 复制客户端ID和客户端密码

2.配置克劳德桌面

Docker(推荐)

拉取预构建的映像并将其添加到您的Claude Desktop配置中(~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "calendar": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "-p", "3000:3000",
        "-v", "calendar-mcp-data:/home/app/.gcp",
        "-e", "GOOGLE_CLIENT_ID",
        "-e", "GOOGLE_CLIENT_SECRET",
        "ghcr.io/solo-ist/calendar-mcp"
      ],
      "env": {
        "GOOGLE_CLIENT_ID": "your-client-id",
        "GOOGLE_CLIENT_SECRET": "your-client-secret"
      }
    }
  }
}
  • -i 启用用于MCP通信的stdio
  • -p 3000:3000 公开OAuth回调端口(身份验证期间需要)
  • -v calendar-mcp-data:/home/app/.gcp 在容器重启过程中持久化令牌
  • 环境变量从Claude Desktop传递

来源

export GOOGLE_CLIENT_ID='your-client-id'
export GOOGLE_CLIENT_SECRET='your-client-secret'
./bin/setup.sh

然后添加到Claude Desktop配置中:

{
  "mcpServers": {
    "calendar": {
      "command": "node",
      "args": ["/path/to/gcp/packages/calendar-mcp/dist/index.js"],
      "env": {
        "GOOGLE_CLIENT_ID": "your-client-id",
        "GOOGLE_CLIENT_SECRET": "your-client-secret"
      }
    }
  }
}

3.身份验证

使用 auth_add_account 启动OAuth流的工具,然后使用 auth_complete.

可用工具

工具 说明
list_events 列出日期范围内的日历事件
get_event 按ID获取详细的事件信息
create_event 创建新的日历事件
delete_event 按ID删除事件
find_free_time 查询日历的忙/闲

身份验证工具

工具 说明
auth_add_account 启动OAuth流以添加Google帐户
auth_complete 使用授权码完成OAuth
auth_list_accounts 列出所有经过身份验证的帐户
auth_remove_account 删除帐户

配置

环境变量

变量 描述
GOOGLE_CLIENT_ID OAuth客户端ID(必需)
GOOGLE_CLIENT_SECRET OAuth客户端密钥(必需)
ENABLED_TOOLS 已启用工具的逗号分隔列表(默认:只读)
GCP_PLAINTEXT_STORAGE 使用明文存储而不是密钥链(用于CI/CD)

范围

默认情况下,只启用只读工具。服务器根据启用的工具请求最小作用域:

  • 只读模式: calendar.events.readonly + calendar.freebusy
  • 读写模式: calendar.events + calendar.freebusy

安全

  • 刷新存储在OS钥匙链中的令牌(macOS security,Linux secret-tool)
  • 访问令牌在到期前5分钟刷新
  • CI/CD的明文回退(启用 GCP_PLAINTEXT_STORAGE=true)
  • 日志中没有令牌

码头工人

预构建图像

docker pull ghcr.io/solo-ist/calendar-mcp

本地建设

docker build -t calendar-mcp .
docker run -i --rm \
  -p 3000:3000 \
  -v calendar-mcp-data:/home/app/.gcp \
  -e GOOGLE_CLIENT_ID='your-client-id' \
  -e GOOGLE_CLIENT_SECRET='your-client-secret' \
  calendar-mcp

发展

pnpm install
pnpm build
pnpm test
pnpm audit