mcpField
G
google-workspace

google-workspace

github.com/letta-ai生产力152126 次安装4 周前更新
代码仓库

关于 google-workspace

通过共享 OAuth 2.0 身份验证执行 Gmail 和 Google Calendar 操作,适用于邮件搜索与草稿、日历查询、空闲时间检查及创建日程等工作流。

主要功能

  1. 01使用共享 OAuth 2.0 凭据认证
  2. 02搜索并读取 Gmail 邮件
  3. 03查找待回复邮件并创建草稿
  4. 04搜索日历并检查空闲时间
  5. 05创建日历活动

适用场景

  1. 01查找并阅读需要回复的邮件
  2. 02准备邮件回复草稿
  3. 03查询会议时段是否空闲
  4. 04创建包含参会者的日程

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/letta-ai/skills --skill google-workspace

安装后在 Claude Code 中输入/google-workspace确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

reference/
search_operators.md
scripts/
calendar_auth.py
create_draft.py
create_event.py
find_busy.py
gmail_auth.py
list_calendars.py
needs_reply.py
read_email.py
search_emails.py
search_events.py

详细介绍

Google Workspace 集成

通过共享的 OAuth 2.0 身份验证访问 Gmail 和 Google Calendar。

先决条件

  1. 已安装 Python 3.10+
  2. 已启用 Gmail API 和 Calendar API 的 Google Cloud 项目
  3. 已下载 OAuth 2.0 凭据(credentials.json)
  4. 所需软件包:google-api-python-client、google-auth-httplib2、google-auth-oauthlib

OAuth 设置

第 1 步:创建 Google Cloud 项目
  1. 访问 https://console.cloud.google.com/
  2. 创建新项目或选择现有项目
  3. 前往 APIs & Services → Library
  4. 启用 Gmail API 和 Google Calendar API
第 2 步:配置 OAuth 同意屏幕
  1. 前往 APIs & Services → OAuth consent screen
  2. 选择 External 用户类型
  3. 添加以下范围:
    • https://www.googleapis.com/auth/gmail.readonly
    • https://www.googleapis.com/auth/gmail.compose
    • https://www.googleapis.com/auth/gmail.modify
    • https://www.googleapis.com/auth/calendar.readonly
    • https://www.googleapis.com/auth/calendar.events
  4. 添加用户的电子邮件地址作为测试用户
第 3 步:创建 OAuth 凭据
  1. 前往 APIs & Services → Credentials
  2. 点击 Create Credentials → OAuth client ID
  3. 选择 Desktop app 作为应用类型
  4. 下载 JSON 文件并将其重命名为 credentials.json
第 4 步:安装依赖项
uv add google-api-python-client google-auth-httplib2 google-auth-oauthlib
第 5 步:首次身份验证

运行任意脚本,它会打开浏览器以进行 OAuth 同意。系统会保存 token.json,供以后使用。


Gmail 操作

搜索邮件
uv run python tools/google-workspace/scripts/search_emails.py "from:[email protected]" --credentials ./credentials.json
阅读邮件内容
uv run python tools/google-workspace/scripts/read_email.py <message_id> --credentials ./credentials.json
创建草稿
uv run python tools/google-workspace/scripts/create_draft.py \
  --to "[email protected]" \
  --subject "Subject line" \
  --body "Email body" \
  --credentials ./credentials.json
查找需要回复的邮件
uv run python tools/google-workspace/scripts/needs_reply.py --credentials ./credentials.json

Calendar 操作

列出日历
uv run python tools/google-workspace/scripts/list_calendars.py --credentials ./credentials.json
搜索日程
# Search by text
uv run python tools/google-workspace/scripts/search_events.py "meeting" --credentials ./credentials.json

# Search by date range
uv run python tools/google-workspace/scripts/search_events.py --start "2024-01-15" --end "2024-01-20" --credentials ./credentials.json
检查可用时间
uv run python tools/google-workspace/scripts/find_busy.py \
  --start "2024-01-15T09:00:00" \
  --end "2024-01-15T17:00:00" \
  --credentials ./credentials.json
创建日程
uv run python tools/google-workspace/scripts/create_event.py \
  --summary "Team Meeting" \
  --start "2024-01-15T10:00:00" \
  --end "2024-01-15T11:00:00" \
  --attendees "[email protected],[email protected]" \
  --credentials ./credentials.json

选项: --description、--location、--timezone、--calendar


脚本参考

Gmail:

  • gmail_auth.py - Gmail 身份验证工具
  • search_emails.py - 使用 Gmail 查询语法搜索收件箱
  • read_email.py - 按邮件 ID 阅读邮件内容
  • create_draft.py - 创建邮件草稿
  • needs_reply.py - 查找等待回复的邮件

Calendar:

  • calendar_auth.py - Calendar 身份验证工具
  • list_calendars.py - 列出可访问的日历
  • search_events.py - 按文本或日期搜索日程
  • find_busy.py - 检查空闲/忙碌时段
  • create_event.py - 创建日历日程

常见工作流

安排会议
  1. 搜索日历中的可用时间:search_events.py --start ... --end ...
  2. 创建日程:create_event.py --summary "..." --start ... --end ...
回复重要邮件
  1. 查找需要回复的邮件:needs_reply.py
  2. 阅读特定邮件:read_email.py <id>
  3. 创建回复草稿:create_draft.py --to ... --subject "Re: ..."

评论

支持 Markdown