Google Docs, Sheets, Drive & Apps Script
You have access to a CLI tool gdoc that performs all Google Docs, Sheets, Drive, and Apps Script operations. Run it via:
node ~/.claude/skills/docmcp/scripts/gdoc.mjs <command> [options-as-json]
All commands accept a single JSON argument. Output is always JSON.
Authentication
The tool uses OAuth tokens stored at ~/.config/gcloud/docmcp/token.json. If tokens are missing, tell the user to run:
node ~/.claude/skills/docmcp/scripts/gdoc.mjs auth
This prints an auth URL. The user visits it, authorizes, and tokens are saved automatically.
Commands Reference
Google Docs
| Command | JSON Args | Description |
|---|---|---|
docs.create | {"title": "..."} | Create a new doc |
docs.read | {"doc_id": "..."} | Read doc text content |
docs.edit | {"doc_id": "...", "old_text": "...", "new_text": "...", "replace_all": false} | Replace text in doc |
docs.insert | {"doc_id": "...", "text": "...", "position": "end"} | Insert text (position: "end", text-to-insert-after, or index number) |
docs.delete | {"doc_id": "...", "text": "...", "delete_all": false} | Delete text from doc |
docs.format | {"doc_id": "...", "search_text": "...", ...formatting} | Format text (bold, italic, underline, strikethrough, font_size, font_family, foreground_color, background_color, heading, alignment) |
docs.insert_table | {"doc_id": "...", "rows": 3, "cols": 3, "position": "end"} | Insert table |
docs.get_info | {"doc_id": "..."} | Get doc metadata |
docs.get_structure | {"doc_id": "..."} | Get headings hierarchy |
docs.get_sections | {"doc_id": "..."} | Parse sections with indices |
docs.section | `{"doc_id": "...", "action": "delete | move |
docs.image | `{"doc_id": "...", "action": "insert | list |
docs.batch | {"doc_id": "...", "operations": [...]} | Batch operations (type: insert/delete/format with params) |
docs.list | {"max_results": 20, "query": "..."} | List docs |
Google Sheets
| Command | JSON Args | Description |
|---|---|---|
sheets.create | {"title": "..."} | Create spreadsheet |
sheets.read | {"sheet_id": "...", "range": "Sheet1"} | Read values from range |
sheets.edit | {"sheet_id": "...", "range": "A1:B2", "values": [[...]]} | Update range values |
sheets.insert | {"sheet_id": "...", "values": [[...]], "range": "Sheet1"} | Append rows |
sheets.get_cell | {"sheet_id": "...", "cell": "A1"} | Get cell value |
sheets.set_cell | {"sheet_id": "...", "cell": "A1", "value": "..."} | Set cell value |
sheets.edit_cell | {"sheet_id": "...", "cell": "A1", "old_text": "...", "new_text": "...", "replace_all": false} | Replace text in cell |
sheets.find_replace | {"sheet_id": "...", "find": "...", "replace": "...", "sheet_name": null} | Find/replace across sheet |
sheets.get_info | {"sheet_id": "..."} | Get spreadsheet metadata |
sheets.list | {"max_results": 20, "query": "..."} | List spreadsheets |
sheets.tab | `{"sheet_id": "...", "action": "add | delete |
sheets.clear | {"sheet_id": "...", "range": "A1:B2", "clear_formats": false} | Clear range |
sheets.format | {"sheet_id": "...", "range": "A1:B2", ...formatting} | Format range (background_color, text_color, bold, italic, font_size, font_family, horizontal_alignment, vertical_alignment, wrap_strategy, number_format, borders) |
sheets.merge | `{"sheet_id": "...", "range": "A1:B2", "action": "merge | unmerge"}` |
sheets.freeze | {"sheet_id": "...", "sheet_name": "...", "rows": 1, "columns": 0} | Freeze rows/columns |
sheets.sort | {"sheet_id": "...", "range": "A1:C10", "sort_column": "A", "ascending": true} | Sort range |
sheets.rows_cols | `{"sheet_id": "...", "sheet_name": "...", "action": "insert | delete", "dimension": "ROW |
sheets.dimension_size | `{"sheet_id": "...", "sheet_name": "...", "dimension": "COLUMN | ROW", "start": "A", "end": "C", "size": 150}` |
sheets.get_formula | {"sheet_id": "...", "cell": "A1"} | Get cell formula and value |
sheets.batch | {"sheet_id": "...", "operations": [...]} | Batch operations (type: setValue/format) |
Google Drive
| Command | JSON Args | Description |
|---|---|---|
drive.search | `{"query": "...", "type": "all | docs |
Apps Script
| Command | JSON Args | Description |
|---|---|---|
scripts.create | {"sheet_id": "...", "script_name": "..."} | Create script project |
scripts.list | {"sheet_id": "..."} | List scripts |
scripts.read | {"sheet_id": "...", "script": "name-or-index"} | Read script files |
scripts.write | `{"sheet_id": "...", "script": "...", "file_name": "...", "content": "...", "file_type": "SERVER_JS | HTML"}` |
scripts.edit | {"sheet_id": "...", "script": "...", "file_name": "...", "old_text": "...", "new_text": "...", "replace_all": false} | Edit script file |
scripts.delete | {"sheet_id": "...", "script": "..."} | Remove script tracking |
scripts.run | {"sheet_id": "...", "script": "...", "function_name": "...", "parameters": []} | Execute script function |
scripts.sync | {"sheet_id": "..."} | Sync and verify scripts |
Gmail
| Command | JSON Args | Description |
|---|---|---|
gmail.list_messages | {"query": "...", "max_results": 10} | List messages (query examples: "from:example@example.com", "is:unread", "subject:meeting") |
gmail.get_message | {"message_id": "...", "format": "full"} | Get message details (format: full, minimal, raw, metadata) |
gmail.send_message | {"to": "...", "subject": "...", "body": "...", "from": "...", "cc": ["..."], "bcc": ["..."]} | Send email |
gmail.list_threads | {"query": "...", "max_results": 10} | List threads |
gmail.get_thread | {"thread_id": "...", "format": "full"} | Get thread details |
gmail.modify_message | {"message_id": "...", "add_labels": ["..."], "remove_labels": ["..."]} | Modify message labels |
gmail.mark_as_read | {"message_id": "..."} | Mark message as read |
gmail.mark_as_unread | {"message_id": "..."} | Mark message as unread |
gmail.trash_message | {"message_id": "..."} | Move message to trash |
gmail.untrash_message | {"message_id": "..."} | Restore message from trash |
gmail.delete_message | {"message_id": "..."} | Permanently delete message |
gmail.list_labels | {} | List all Gmail labels |
gmail.get_label | {"label_id": "..."} | Get label details |
Usage Pattern
Always use this exact invocation pattern:
node ~/.claude/skills/docmcp/scripts/gdoc.mjs <command> '<json-args>'
Example: Create a document:
node ~/.claude/skills/docmcp/scripts/gdoc.mjs docs.create '{"title":"Meeting Notes"}'
Example: Read a spreadsheet:
node ~/.claude/skills/docmcp/scripts/gdoc.mjs sheets.read '{"sheet_id":"1abc...xyz","range":"Sheet1!A1:D10"}'
Example: Format text bold in a doc:
node ~/.claude/skills/docmcp/scripts/gdoc.mjs docs.format '{"doc_id":"1abc...xyz","search_text":"Important","bold":true}'
For detailed API reference with all field options, see reference.md. For usage examples, see examples.md.