返回市场
日历自动认证MCP服务器

日历自动认证MCP服务器

作者:GongRzhe10 星标更新:2025-03-11

项目介绍

Calendar AutoAuth MCP Server

用于在Claude Desktop中集成Google日历并支持自动认证的Model Context Protocol (MCP)服务器。此服务器使AI助手能够通过自然语言交互管理Google日历事件。

smithery badge npm version License: ISC

功能

  • 创建带有标题、时间、描述和地点的日历事件
  • 根据事件ID检索事件详情
  • 更新现有事件(标题、时间、描述、地点)
  • 删除事件
  • 列出指定时间段内的事件
  • 完整集成Google日历API
  • 简单的OAuth2认证流程,自动启动浏览器
  • 支持桌面应用和Web应用凭证
  • 全局凭证存储以方便使用

安装与认证

通过Smithery安装

要通过Smithery自动安装Claude Desktop的Calendar AutoAuth Server:

npx -y @smithery/cli install @gongrzhe/server-calendar-autoauth-mcp --client claude
  1. 创建一个Google云项目并获取凭证:

    a. 创建一个Google云项目:

    • 访问Google云控制台
    • 创建一个新的项目或选择现有的项目
    • 启用项目的Google日历API

    b. 创建OAuth 2.0凭证:

    • 转到“API和服务”>“凭证”
    • 点击“创建凭证”>“OAuth客户端ID”
    • 选择“桌面应用”或“Web应用”作为应用类型
    • 给它命名并点击“创建”
    • 对于Web应用,请添加http://localhost:3000/oauth2callback到授权重定向URI
    • 下载客户端的OAuth密钥的JSON文件
    • 将密钥文件重命名为gcp-oauth.keys.json
  2. 运行认证:

    您可以通过两种方式认证:

    a. 全局认证(推荐):

    # 第一次:将gcp-oauth.keys.json放置在您的家目录下的.calendar-mcp文件夹中
    mkdir -p ~/.calendar-mcp
    mv gcp-oauth.keys.json ~/.calendar-mcp/
    
    # 从任何地方运行认证
    npx @gongrzhe/server-calendar-autoauth-mcp auth
    

    b. 局部认证:

    # 将gcp-oauth.keys.json放置在当前目录下
    # 文件将被自动复制到全局配置
    npx @gongrzhe/server-calendar-autoauth-mcp auth
    

    认证过程会:

    • 在当前目录或~/.calendar-mcp/查找gcp-oauth.keys.json
    • 如果在当前目录找到,则将其复制到~/.calendar-mcp/
    • 打开默认浏览器进行Google认证
    • 将凭证保存为~/.calendar-mcp/credentials.json

    注意

    • 成功认证后,凭证会被全局存储在~/.calendar-mcp/,可以从任何目录使用
    • 支持桌面应用和Web应用凭证
    • 对于Web应用凭证,请确保添加http://localhost:3000/oauth2callback到您的授权重定向URI
  3. 在Claude Desktop中配置:

{
  "mcpServers": {
    "calendar": {
      "command": "npx",
      "args": [
        "@gongrzhe/server-calendar-autoauth-mcp"
      ]
    }
  }
}

Docker支持

如果您更喜欢使用Docker:

  1. 认证:
docker run -i --rm \
  --mount type=bind,source=/path/to/gcp-oauth.keys.json,target=/gcp-oauth.keys.json \
  -v mcp-calendar:/calendar-server \
  -e CALENDAR_OAUTH_PATH=/gcp-oauth.keys.json \
  -e "CALENDAR_CREDENTIALS_PATH=/calendar-server/credentials.json" \
  -p 3000:3000 \
  mcp/calendar auth
  1. 使用:
{
  "mcpServers": {
    "calendar": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-v",
        "mcp-calendar:/calendar-server",
        "-e",
        "CALENDAR_CREDENTIALS_PATH=/calendar-server/credentials.json",
        "mcp/calendar"
      ]
    }
  }
}

使用示例

该服务器提供了几个可通过Claude Desktop使用的工具:

创建事件

{
  "summary": "团队会议",
  "start": {
    "dateTime": "2024-01-20T10:00:00Z"
  },
  "end": {
    "dateTime": "2024-01-20T11:00:00Z"
  },
  "description": "每周团队同步",
  "location": "会议室A"
}

列出事件

{
  "timeMin": "2024-01-01T00:00:00Z",
  "timeMax": "2024-12-31T23:59:59Z",
  "maxResults": 10,
  "orderBy": "startTime"
}

更新事件

{
  "eventId": "event123",
  "summary": "更新后的会议标题",
  "start": {
    "dateTime": "2024-01-20T11:00:00Z"
  },
  "end": {
    "dateTime": "2024-01-20T12:00:00Z"
  }
}

删除事件

{
  "eventId": "event123"
}

安全注意事项

  • OAuth凭证安全地存储在本地环境(~/.calendar-mcp/
  • 服务器使用离线访问来维持持久认证
  • 不要分享或提交您的凭证到版本控制系统
  • 定期审查并撤销Google账户设置中的未使用访问权限
  • 凭证存储是全局的,但仅限当前用户访问

故障排除

  1. 找不到OAuth密钥

    • 确保gcp-oauth.keys.json在当前目录或~/.calendar-mcp/
    • 检查文件权限
  2. 无效凭证格式

    • 确保您的OAuth密钥文件包含webinstalled凭证
    • 对于Web应用,请验证重定向URI是否正确配置
  3. 端口已被占用

    • 如果端口3000已被占用,请在运行认证之前释放它
    • 您可以找到并停止使用该端口的过程

贡献

欢迎贡献!请随时提交Pull Request。

许可证

本项目采用ISC许可证。

作者

gongrzhe

支持

如果您遇到任何问题或有疑问,请在GitHub仓库中提交Issue。