Google Calendar MCP Server

Google Calendar MCP Server

site icon
2025.03.20 0
TypeScriptGoogle Calendar 集成日程管理事件管理日程管理
Google Calendar MCP Server 是一个基于 TypeScript 构建的 Model Context Protocol (MCP) 服务器,用于与 Google Calendar 集成。它提供了无缝的 Google Calendar 集成功能,包括 OAuth 2.0 认证、持久化令牌存储、日历和事件的全面管理操作,以及实时更新的 Server-Sent Events (SSE) 传输选项。
View on GitHub

Overview

基本能力

产品定位

Google Calendar MCP Server 是一个用于与 Google Calendar 集成的 MCP 服务器,旨在简化日历和事件的管理操作,并提供实时更新功能。

核心功能

  • 无缝的 Google Calendar 集成,支持 OAuth 2.0 认证
  • 持久化令牌存储,实现自动认证
  • 列出和管理日历,支持全面的事件操作
  • 创建、读取、更新和删除日历事件
  • 获取指定日期范围内的日历事件
  • Server-Sent Events (SSE) 传输选项,支持实时更新
  • 与 Claude 和其他 MCP 兼容的 AI 助手简单集成

适用场景

  • 需要自动化管理 Google Calendar 事件的场景
  • 需要实时获取日历事件更新的场景
  • 需要与 AI 助手集成以管理日历的场景

工具列表

工具 描述
list_calendars 获取所有可用的日历
list_calendar_events 检索指定日期范围内的事件
create_calendar_event 向日历添加新事件
get_calendar_event 获取特定事件的详细信息
edit_calendar_event 修改现有的日历事件
delete_calendar_event 从日历中删除事件

常见问题解答

  • 如何获取 OAuth 2.0 凭证? 需要在 Google Cloud Console 中创建项目并启用 Google Calendar API,然后配置 OAuth 同意屏幕并创建 OAuth 客户端 ID。
  • 如何存储认证令牌? 首次认证后,令牌会保存到 token.json 文件中,后续启动时会自动使用该令牌。
  • 如何保护敏感信息? 不要将 credentials.jsontoken.json 提交到版本控制或公开分享,如果怀疑凭证泄露,应立即在 Google Cloud Console 中撤销。

使用教程

使用依赖

  1. Node.js (v16 或更高版本)
  2. Google Cloud Platform 账户
  3. 启用的 Google Calendar API
  4. OAuth 2.0 凭证

安装教程

npm install -g mcp-google-calendar

或直接运行:

npx -y mcp-google-calendar

Google Cloud 配置

  1. 访问 Google Cloud Console
  2. 创建新项目或选择现有项目
  3. 启用 Google Calendar API
  4. 配置 OAuth 同意屏幕
  5. 创建 OAuth 凭证并下载 credentials.json 文件

环境配置

创建 .env 文件:

# Server configuration
PORT=3420

# Google Calendar API configuration
CREDENTIALS_PATH=./credentials.json

启动服务器

使用标准 WebSockets 启动:

npx -y mcp-google-calendar

使用 Server-Sent Events (SSE) 启动:

npx -y mcp-google-calendar --sse

与 Claude Desktop 集成

claude_desktop_config.json 中添加:

{
   "mcpServers": {
      "mcp-google-calendar": {
         "command": "npx",
         "args": ["-y", "mcp-google-calendar"],
         "env": {
            "CREDENTIALS_PATH": "/path/to/your/credentials.json"
         }
      }
   }
}

调试方式

  1. 首次运行时,浏览器窗口会自动打开,要求登录 Google 账户并授权
  2. 检查 token.json 是否生成
  3. 使用工具列表中的命令测试功能,如 list_calendars
  4. 查看服务器日志以确认事件操作是否成功

许可证

该项目遵循 MIT 开源许可条款,请参阅 MIT 了解完整条款。