mcpField
G
google

google

github.com/odyssey4me生产力13842 次安装1 天前更新
代码仓库

关于 google

面向 Agent 的 Google Workspace 技能,通过 `gog` 命令行操作 Gmail、Calendar、Drive、Docs、Sheets 和 Slides,并提供结构化输出与操作安全选项。

主要功能

  1. 01搜索和读取 Gmail
  2. 02管理 Calendar 事件与空闲时间
  3. 03浏览和搜索 Drive 文件
  4. 04操作 Docs、Sheets 和 Slides
  5. 05支持 JSON 与 TSV 输出
  6. 06只读和 dry-run 安全选项

适用场景

  1. 01查找并汇总近期邮件
  2. 02安排会议前查看空闲时间
  3. 03搜索并导出近期 Drive 文档
  4. 04创建或更新 Workspace 文档与表格

安装

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

$npx skills add https://github.com/odyssey4me/agent-skills --skill google

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

包含的文件

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

references/
calendar.md
configuration.md
docs-workflows.md
docs.md
drive.md
gmail.md
permissions.md
sheets.md
slides.md

详细介绍

Google Workspace 技能

此技能通过 gog CLI(gogcli)集成 Google Workspace。Agent 会直接调用 gog 执行所有操作。

前提条件

安装 gog 二进制文件(CI 验证的版本列于上方的 frontmatter 中):

# Homebrew
brew install openclaw/tap/gogcli

# Manual (Linux amd64)
curl -sL https://github.com/openclaw/gogcli/releases/latest/download/gogcli_VERSION_linux_amd64.tar.gz | tar xz
mv gog ~/.local/bin/

容器和 MCP 服务替代方案请参阅 configuration.md。

网络访问

Google Workspace 命令需要通过 HTTPS 连接到 Google API 和 OAuth 端点,包括身份验证和令牌刷新。远程操作需要出站网络访问。如果 Agent 环境对此有限制,请在首次执行远程命令前,通过该环境的审批或网络控制获得访问权限,并重复使用已授予的授权。本地帮助和文件处理无需网络访问。技能说明不会授予网络权限。DNS、连接和超时故障应报告为网络错误;不要通过重置凭据来解决。若已批准的访问仍然失败,请停止操作并报告。身份验证和权限错误需要用户处理。

身份验证

# Import credentials.json from Google Cloud Console
gog auth credentials set /path/to/credentials.json

# Authorize with only the services you need (opens browser)
gog auth add [email protected] --services gmail,calendar,drive,docs,sheets,slides

# Verify
gog auth doctor

快速参考

gog gmail search "is:unread"                    # Search email
gog calendar events --today                     # Today's events
gog drive search "quarterly report"             # Search files
gog docs cat <docId>                            # Read a document
gog sheets get <spreadsheetId> "Sheet1!A1:D10"  # Read spreadsheet range
gog slides info <presentationId>                # Presentation metadata

所有命令都支持使用 --json 输出结构化数据,使用 --plain 输出 TSV。

命令

Gmail
# Search
gog gmail search "from:[email protected] newer_than:7d"
gog gmail search "is:unread label:inbox" --max 20

# Read
gog gmail get <messageId>
gog gmail thread get <threadId>
gog gmail labels list

# Organize
gog gmail mark-read <messageId>
gog gmail unread <messageId>
gog gmail archive <messageId>
gog gmail trash <messageId>

# Send
gog gmail send --to "[email protected]" --subject "Hello" --body "Message body"
gog gmail reply <messageId> --body "Reply text"
gog gmail forward <messageId> --to "[email protected]"

# Drafts
gog gmail drafts list
gog gmail drafts create --to "[email protected]" --subject "Draft" --body "Content"
gog gmail drafts send <draftId>

完整命令参考请参阅 gmail.md。

Google Calendar
# View
gog calendar calendars
gog calendar events --today
gog calendar events --from "2026-06-25" --to "2026-06-30"
gog calendar event <calendarId> <eventId>
gog calendar freebusy --from "2026-06-25T09:00:00Z" --to "2026-06-25T17:00:00Z"
gog calendar search "standup"

# Create
gog calendar create primary --summary "Meeting" --from "2026-06-25T10:00:00" --to "2026-06-25T11:00:00"

# Manage
gog calendar update <calendarId> <eventId> --summary "Updated title"
gog calendar delete <calendarId> <eventId>
gog calendar respond <calendarId> <eventId> --status accepted

完整命令参考请参阅 calendar.md。

Google Drive
# Browse
gog drive ls
gog drive ls --folder <folderId>
gog drive search "quarterly report"
gog drive tree
gog drive get <fileId>

# File operations
gog drive upload report.pdf --parent <folderId>
gog drive download <fileId>
gog drive copy <fileId> "Copy of Report"
gog drive move <fileId> --parent <newFolderId>
gog drive rename <fileId> "New Name"
gog drive delete <fileId>

# Sharing
gog drive share <fileId> --email "[email protected]" --role writer
gog drive permissions <fileId>
gog drive unshare <fileId> <permissionId>

完整命令参考请参阅 drive.md。

Google Docs
# Read
gog docs info <docId>
gog docs cat <docId>
gog docs export <docId> --format md
gog docs structure <docId>

# Write
gog docs create "New Document"
gog docs write <docId> --body "Content to append"
gog docs insert <docId> "Text to insert" --at 1
gog docs find-replace <docId> "old text" "new text"
gog docs format <docId> --bold --start 1 --end 10

# Tables
gog docs insert-table <docId> --rows 3 --cols 4
gog docs cell-update <docId> --row 1 --col 1 --body "Header"

完整命令参考请参阅 docs.md。

Docs 工作流

如需了解如何导入保留格式和表格样式的 Markdown,并进行往返编辑,请参阅 docs-workflows.md。

# Import markdown as a new document with standard formatting
gog docs create "Document Title" --file document.md --pageless
gog docs format <docId> --line-spacing 115 --space-below 8

# Update an existing document from markdown with formatting
gog docs write <docId> --file document.md --markdown --replace --pageless
gog docs format <docId> --line-spacing 115 --space-below 8
Google Sheets
# Read
gog sheets metadata <spreadsheetId>
gog sheets get <spreadsheetId> "Sheet1!A1:D10"
gog sheets get <spreadsheetId> "Sheet1!A:A" --format FORMULA

# Write
gog sheets create "New Spreadsheet"
gog sheets update <spreadsheetId> "Sheet1!A1" "value1" "value2" "value3"
gog sheets append <spreadsheetId> "Sheet1!A:D" "val1" "val2" "val3" "val4"
gog sheets clear <spreadsheetId> "Sheet1!A1:D10"

# Structure
gog sheets add-tab <spreadsheetId> "New Tab"
gog sheets delete-tab <spreadsheetId> "Old Tab"
gog sheets rename-tab <spreadsheetId> "Old Name" "New Name"

完整命令参考请参阅 sheets.md。

Google Slides
# Read
gog slides info <presentationId>
gog slides list-slides <presentationId>
gog slides read-slide <presentationId> <slideId>
gog slides export <presentationId> --format pptx

# Create
gog slides create "New Presentation"
gog slides create-from-markdown "Deck Title" --file slides.md
gog slides create-from-template <templateId> "From Template" --replacements '{"{{NAME}}":"Value"}'

# Edit
gog slides new-slide <presentationId>
gog slides insert-text <presentationId> <objectId> "Text content"
gog slides replace-text <presentationId> "find" "replace"
gog slides insert-image <presentationId> <slideId> image.png --width 300

完整命令参考请参阅 slides.md。

示例

搜索并总结近期邮件
gog gmail search "is:unread newer_than:7d" --json --results-only | jq '.[] | "\(.from): \(.subject)"'
创建明天的日历活动
TOMORROW=$(date -d '+1 day' '+%Y-%m-%dT09:00:00')
gog calendar create primary --summary "Team Standup" --from "$TOMORROW" --to "${TOMORROW%T*}T09:30:00"
下载近期文档
gog drive search "type:document newer_than:7d" --json --results-only | jq -r '.[] | .id' | \
  while read docId; do gog docs export "$docId" --format md > "doc_$docId.md"; done
查询会议时间是否有空
gog calendar freebusy --from "2026-06-25T09:00:00Z" --to "2026-06-25T17:00:00Z"

输出格式

# JSON output (structured, for scripting)
gog gmail search "is:unread" --json --results-only

# Plain/TSV output (stable, parseable)
gog drive ls --plain

# Select specific fields
gog gmail search "is:unread" --json --select "id,subject,from"

Agent 安全

# Read-only mode (blocks all mutations)
gog --readonly gmail search "test"

# Block Gmail send specifically
gog --gmail-no-send gmail search "test"

# Preview actions without executing
gog --dry-run drive delete <fileId>

# Disable interactive prompts (fail instead)
gog --no-input calendar create primary --summary "Test"

错误处理

退出代码含义可重试
0成功-
3结果为空否(正常情况)
4需要身份验证否(运行 gog auth setup)
5未找到否
6权限被拒绝否
7受到速率限制是(等待后重试)
8可重试的服务器错误是(等待后重试)

身份验证和权限错误需要用户介入。速率限制和服务器错误可在短暂等待后重试。

评论

支持 Markdown