SuperAPI AI 工具集

google-docs

办公与效率

查看项目

更新于 10-15 18:09

技能介绍

用途

Google Docs 是一个轻量级的 Google Docs 集成技能,用于与 Google Docs 进行交互,包括创建文档、按标题搜索、读取内容以及编辑文本。它采用独立的 OAuth 认证方式,无需 MCP 服务器。

主要能力

  • 创建新文档,可指定标题,也可附带初始内容。
  • 按标题查找文档,支持限制返回数量。
  • 获取文档的文本内容,支持使用文档 ID 或完整 URL。
  • 向文档末尾追加文本。
  • 在文档开头插入文本。
  • 替换文档中的指定文本。

使用方式

首次设置

使用 Google 进行认证(会打开浏览器):

python scripts/auth.py login

检查认证状态:

python scripts/auth.py status

登出:

python scripts/auth.py logout

命令

所有操作通过 scripts/docs.py 执行。如果未登录,首次使用时会自动认证。

创建新文档:

python scripts/docs.py create "Meeting Notes"

创建带初始内容的文档:

python scripts/docs.py create "Project Plan" --content "# Overview\n\nThis is the project plan."

按标题查找文档:

python scripts/docs.py find "meeting" --limit 10

获取文档的文本内容:

python scripts/docs.py get-text 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms

使用完整 URL 获取文本:

python scripts/docs.py get-text "https://docs.google.com/document/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit"

向文档末尾追加文本:

python scripts/docs.py append-text 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms "New paragraph at the end."

在文档开头插入文本:

python scripts/docs.py insert-text 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms "Text at the beginning.\n\n"

替换文档中的文本:

python scripts/docs.py replace-text 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms "old text" "new text"

文档 ID 格式

Google Docs 使用类似 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms 的文档 ID。你可以:

  • 使用完整 URL(会自动提取 ID)
  • 仅使用文档 ID
  • 从 find 命令的结果中获取文档 ID

令牌管理

令牌通过系统密钥环安全存储:

  • macOS:Keychain
  • Windows:Windows Credential Locker
  • Linux:Secret Service API(GNOME Keyring、KDE Wallet 等)

服务名称:google-docs-skill-oauth

访问令牌过期时会使用 Google 的云函数自动刷新。

适用场景

适用于需要以编程方式操作 Google Docs 的场景,例如自动创建会议记录、项目计划文档,查找和读取文档内容,或对文档进行文本追加、插入和替换等编辑操作。

限制

  • 需要 Google Workspace 账号,不支持个人 Gmail 账号。
  • 其他限制暂未提供。