mcpField
G
gmail

gmail

github.com/the-focus-ai生产力5119 次安装15 周前更新
代码仓库

关于 gmail

面向 Claude 的技能,通过 TypeScript 命令行脚本管理 Gmail 邮件和 Google Calendar 日程。支持邮件搜索、读取与发送,以及日程操作和 Markdown 样式邮件。

主要功能

  1. 01搜索、列出、读取和发送 Gmail 邮件
  2. 02列出日历并管理日程
  3. 03将 Markdown 转为样式化 HTML 邮件
  4. 04通过 Google OAuth 进行身份验证
  5. 05以 JSON 返回命令结果

适用场景

  1. 01查找未读邮件或指定发件人的邮件
  2. 02通过命令行读取或发送邮件
  3. 03查看即将举行的日历活动
  4. 04发送由 Markdown 格式化的邮件

安装

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

$npx skills add https://github.com/the-focus-ai/google-skill --skill gmail

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

包含的文件

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

references/
api-patterns.md
setup-guide.md
scripts/
gmail.ts

详细介绍

Gmail 和 Calendar 技能

读取、发送和搜索 Gmail。列出、创建和删除日历活动。

首次设置

运行 npx tsx ${CLAUDE_PLUGIN_ROOT}/skills/gmail/scripts/gmail.ts auth,通过 Google 进行身份验证。这会打开浏览器以征求 OAuth 授权。

令牌按项目存储在 .claude/google-skill.local.json 中。

使用自己的凭据(可选)

默认情况下,此技能使用内置 OAuth 凭据。若要改用自己的 Google Cloud 项目凭据:

  1. 创建 Google Cloud 项目,并启用所需的 API(Gmail、Calendar、Sheets、Docs、YouTube、Drive)
  2. 创建 OAuth 2.0 凭据(桌面应用类型)
  3. 下载 JSON 文件,并保存到 ~/.config/google-skill/credentials.json

如果该文件存在,此技能会自动使用其中的凭据。

Gmail 命令

# List messages
npx tsx ${CLAUDE_PLUGIN_ROOT}/skills/gmail/scripts/gmail.ts list
npx tsx ${CLAUDE_PLUGIN_ROOT}/skills/gmail/scripts/gmail.ts list --query="is:unread" --max=5

# Read message
npx tsx ${CLAUDE_PLUGIN_ROOT}/skills/gmail/scripts/gmail.ts read <message-id>

# Send email (plain text)
npx tsx ${CLAUDE_PLUGIN_ROOT}/skills/gmail/scripts/gmail.ts send \
  --to="[email protected]" \
  --subject="Hello" \
  --body="Message content"

# Send HTML email
npx tsx ${CLAUDE_PLUGIN_ROOT}/skills/gmail/scripts/gmail.ts send \
  --to="[email protected]" \
  --subject="Hello" \
  --body="Plain text fallback" \
  --html="<h1>Hello</h1><p>HTML content</p>"

# Send with attachments
npx tsx ${CLAUDE_PLUGIN_ROOT}/skills/gmail/scripts/gmail.ts send \
  --to="[email protected]" \
  --subject="With files" \
  --body="See attached" \
  --attachment="/path/to/file.pdf,/path/to/other.docx"

# Send HTML with inline images
npx tsx ${CLAUDE_PLUGIN_ROOT}/skills/gmail/scripts/gmail.ts send \
  --to="[email protected]" \
  --subject="Newsletter" \
  --body="Plain text version" \
  --html="<h1>Hello</h1><img src='cid:logo'>" \
  --inline="/path/to/logo.png:logo"

# Labels
npx tsx ${CLAUDE_PLUGIN_ROOT}/skills/gmail/scripts/gmail.ts labels
npx tsx ${CLAUDE_PLUGIN_ROOT}/skills/gmail/scripts/gmail.ts label <id> --add="IMPORTANT"

# Download as EML
npx tsx ${CLAUDE_PLUGIN_ROOT}/skills/gmail/scripts/gmail.ts download <message-id>

# Send markdown as styled HTML email (Focus.AI branding)
npx tsx ${CLAUDE_PLUGIN_ROOT}/skills/gmail/scripts/gmail.ts send-md \
  --to="[email protected]" \
  --file="/path/to/report.md" \
  --style=client  # or "labs" for Focus.AI Labs style

# Subject defaults to first H1 in markdown, or specify explicitly:
npx tsx ${CLAUDE_PLUGIN_ROOT}/skills/gmail/scripts/gmail.ts send-md \
  --to="[email protected]" \
  --file="report.md" \
  --style=labs \
  --subject="Weekly Report"

# Create as draft instead of sending:
npx tsx ${CLAUDE_PLUGIN_ROOT}/skills/gmail/scripts/gmail.ts send-md \
  --to="[email protected]" \
  --file="report.md" \
  --draft

# Create a draft email (plain text or HTML)
npx tsx ${CLAUDE_PLUGIN_ROOT}/skills/gmail/scripts/gmail.ts draft \
  --to="[email protected]" \
  --subject="Draft Subject" \
  --body="Draft content"

# Create HTML draft with attachments
npx tsx ${CLAUDE_PLUGIN_ROOT}/skills/gmail/scripts/gmail.ts draft \
  --to="[email protected]" \
  --subject="Draft with files" \
  --body="Plain text fallback" \
  --html="<h1>Hello</h1>" \
  --attachment="/path/to/file.pdf"

样式化邮件模板

send-md 命令会根据 Focus.AI 品牌指南将 Markdown 转换为精美的 HTML 邮件:

  • client(默认):专业风格,采用青绿色点缀、细致的边框和圆角
  • labs:大胆的实验风格,采用黑色边框、阴影和大写标题

支持:标题、粗体/斜体、链接、代码块、表格、列表、引用块、水平线。

Calendar 命令

# List calendars
npx tsx ${CLAUDE_PLUGIN_ROOT}/skills/gmail/scripts/gmail.ts calendars

# List upcoming events
npx tsx ${CLAUDE_PLUGIN_ROOT}/skills/gmail/scripts/gmail.ts events
npx tsx ${CLAUDE_PLUGIN_ROOT}/skills/gmail/scripts/gmail.ts events --max=20

# Get event details
npx tsx ${CLAUDE_PLUGIN_ROOT}/skills/gmail/scripts/gmail.ts event <event-id>

# Create event
npx tsx ${CLAUDE_PLUGIN_ROOT}/skills/gmail/scripts/gmail.ts create \
  --summary="Meeting" \
  --start="2026-01-15T10:00:00" \
  --end="2026-01-15T11:00:00" \
  --location="Conference Room" \
  --description="Discuss project"

# Delete event
npx tsx ${CLAUDE_PLUGIN_ROOT}/skills/gmail/scripts/gmail.ts delete <event-id>

搜索运算符(Gmail)

运算符示例说明
from:from:[email protected]发件人
to:to:[email protected]收件人
subject:subject:meeting主题包含
is:unreadis:unread仅未读邮件
has:attachmenthas:attachment包含附件
newer_than:newer_than:7dN 天以内
label:label:work带有标签

输出

所有命令都会返回包含 success 和 data 字段的 JSON。

检查身份验证

npx tsx ${CLAUDE_PLUGIN_ROOT}/skills/gmail/scripts/gmail.ts check

帮助

npx tsx ${CLAUDE_PLUGIN_ROOT}/skills/gmail/scripts/gmail.ts --help

评论

支持 Markdown