mcpField
G
google-docs

google-docs

github.com/acedatacloudDocuments17167 installsUpdated 1d ago
Repository

About google-docs

A command-line skill for reading, creating, and editing Google Docs through the Google Docs REST API. It guides agents using curl and jq, with notes on authentication scopes and index-based edits.

Key features

  1. 01Read document titles and text
  2. 02Create documents
  3. 03Insert text with batchUpdate
  4. 04Handle OAuth scopes and API errors
  5. 05Extract text with jq

Use cases

  1. 01Retrieve text from a Google Doc
  2. 02Create meeting notes
  3. 03Insert text into an existing document

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/acedatacloud/skills --skill google-docs

After installing, type/google-docsin Claude Code to confirm it loaded.

Details

From the project README

Drive Google Docs via curl + jq. The user's OAuth bearer token is in $GOOGLE_DOCS_TOKEN; every call needs Authorization: Bearer $GOOGLE_DOCS_TOKEN. Base URL: https://docs.googleapis.com/v1/documents. The token carries documents.readonly (+ identity); writes need documents.

Failures are {"error":{"code","message","status"}} — show verbatim. 401 = re-install. 403 PERMISSION_DENIED on a write = read-only scope.

The doc id is the …/document/d/<ID>/edit segment of the URL.

D="https://docs.googleapis.com/v1/documents"; AUTH="Authorization: Bearer $GOOGLE_DOCS_TOKEN"
# Read the document. The body is a tree of structural elements; pull plain text:
curl -sS -H "$AUTH" "$D/DOC_ID" \
  | jq -r '.title, ([.body.content[]?.paragraph?.elements[]?.textRun?.content] | join(""))'

Create & edit

# Create an empty doc
curl -sS -X POST -H "$AUTH" -H "Content-Type: application/json" \
  -d '{"title":"Meeting notes 2026-06-21"}' "$D" | jq '{documentId, title}'

# Insert text at the start (index 1) via batchUpdate (confirm first)
curl -sS -X POST -H "$AUTH" -H "Content-Type: application/json" \
  -d '{"requests":[{"insertText":{"location":{"index":1},"text":"Hello\n"}}]}' \
  "$D/DOC_ID:batchUpdate" | jq '.documentId'

# Replace all occurrences of a placeholder
curl -sS -X POST -H "$AUTH" -H "Content-Type: application/json" \
  -d '{"requests":[{"replaceAllText":{"containsText":{"text":"{{name}}","matchCase":true},"replaceText":"Alex"}}]}' \
  "$D/DOC_ID:batchUpdate" | jq '.replies'

Gotchas

  • The document model is index-based: text edits target character indices, and every insert shifts later indices — for multiple inserts, apply them back-to-front or recompute indices between calls.
  • To get clean Markdown/plain text, walk body.content[].paragraph.elements[] .textRun.content (the jq above). Tables / lists need deeper traversal.
  • Creating a doc puts it in the user's Drive root; use the google-drive skill to move/share it.

Comments

Markdown supported