返回 MCP 目录
public公开dns本地运行

google-calendar-mcp-server-xon

一个基于MCP协议的Google Calendar API服务端,提供日历事件的程序化管理功能

article

README

🚀 Google 日历 MCP 服务器

Google 日历 MCP 服务器是一个模型上下文协议(MCP)服务器,它提供了与 Google Calendar API 交互的工具。通过 MCP 接口,该服务器能够实现对日历事件的程序化管理,让用户更便捷地操作日历。

🚀 快速开始

本服务器可帮助你通过 MCP 接口程序化管理 Google 日历事件。在使用前,请确保满足先决条件并完成安装。

✨ 主要特性

日历工具

  • list_events:按日期范围筛选显示即将来临的日历活动。
  • create_event:创建新的日历事件并添加参与者。
  • update_event:更新现有日历事件。
  • delete_event:删除日历事件。

📦 安装指南

先决条件

  1. Node.js:安装 Node.js 版本 14 或更高。
  2. Google Cloud Console 设置
    • 访问Google Cloud Console
    • 创建新项目或选择现有项目。
    • 启用 Google Calendar API:
      1. 进入"APIs & Services" > "Library"。
      2. 搜索并启用"Google Calendar API"。
    • 设置 OAuth 2.0 凭证:
      1. 进入"APIs & Services" > "Credentials"。
      2. 点击"Create Credentials" > "OAuth client ID"。
      3. 选择"Web 应用程序"。
      4. 将"Authorized redirect URIs"设为:http://localhost:3000/code
      5. 记录下 Client ID 和 Client Secret。

安装步骤

  1. 克隆并安装

    git clone https://github.com/yourusername/google-calendar-mcp-server.git
    cd google-calendar-mcp-server
    npm install
    
  2. 创建 OAuth 凭证: 在根目录下创建credentials.json文件:

    {
        "web": {
            "client_id": "YOUR_CLIENT_ID",
            "client_secret": "YOUR_CLIENT_SECRET",
            "redirect_uris": ["http://localhost:3000/code"],
            "auth_uri": "https://accounts.google.com/o/oauth2/auth",
            "token_uri": "https://oauth2.googleapis.com/token"
        }
    }
    
  3. 获取刷新令牌

    node get-refresh-token.js
    

    此命令将:

    • 打开浏览器进行 Google OAuth 身份验证。
    • 请求以下权限:
      • https://www.googleapis.com/auth/calendar
    • 将凭证保存到token.json
    • 在控制台显示刷新令牌。
  4. 配置 MCP 设置: 将服务器配置添加到您的 MCP 设置文件中:

    • 对于 VSCode Claude 扩展:~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
    • 对于 Claude 桌面应用:~/Library/Application Support/Claude/claude_desktop_config.json

    mcpServers对象中添加如下配置:

    {
      "mcpServers": {
        "google-calendar": {
          "command": "node",
          "args": ["index.js"],
          "cwd": "/path/to/server/directory"
        }
      }
    }
    

💻 使用示例

基础用法

列出即将来临的事件

{
  "action": "list_events",
  "params": {
    "calendarId": "primary", // 可选,默认为"primary"
    "timeMin": "2023-12-01T00:00:00Z", // 开始时间
    "timeMax": "2023-12-31T23:59:59Z", // 结束时间
    "maxResults": 50, // 最大结果数,默认为25
    "orderBy": "startTime" // 按开始时间排序,可选值:startTime, endDate
  }
}

创建新事件

{
  "action": "create_event",
  "params": {
    "calendarId": "primary", 
    "event": {
      "summary": "会议", // 事件标题
      "location": "在线会议", // 事件地点
      "description": "参加团队会议", // 事件描述
      "start": {
        "dateTime": "2023-12-10T10:00:00Z", // 开始时间
        "timeZone": "Asia/Shanghai" // 时间区
      },
      "end": {
        "dateTime": "2023-12-10T11:00:00Z",
        "timeZone": "Asia/Shanghai"
      }
    }
  }
}

更新事件

{
  "action": "update_event",
  "params": {
    "calendarId": "primary", 
    "eventId": "abc123", // 要更新的事件ID
    "event": {
      "summary": "更新会议", // 新标题
      "description": "更新会议内容" // 新描述
    }
  }
}

删除事件

{
  "action": "delete_event",
  "params": {
    "calendarId": "primary", 
    "eventId": "abc123"
  }
}

📄 许可证

本项目使用 MIT 许可证,详情请查看LICENSE文件。

help

运行方式说明

cloud

托管运行

托管运行通常表示这个 MCP Server 由服务方环境承载,用户一般按页面提供的连接方式或授权流程接入,不需要在本地长期启动一个 MCP 进程

  1. 打开服务方连接页
  2. 完成授权或复制端点
  3. 在 MCP 客户端中连接
terminal

本地运行 / 其它方式

本地运行通常需要用户在自己的电脑或服务器上安装依赖,把 server_config 复制到 MCP 客户端,并按 env_schema 补齐环境变量、密钥或其它配置

  1. 复制 server_config
  2. 安装所需依赖
  3. 补齐环境变量后重启客户端