MCPInstall

google-docs

Create and modify Google Docs documents. Read content, insert tables, apply heading styles, and manage formatting. Use when asked to edit a gdoc, write a Google document, update a doc, or format document content.

Installs
262
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/odyssey4me/agent-skills --skill google-docs
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads google-docs automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

Google Docs

Interact with Google Docs for document creation, editing, and content management.

Installation

Dependencies: pip install --user google-auth google-auth-oauthlib google-api-python-client keyring pyyaml markdown-it-py

Setup Verification

After installation, verify the skill is properly configured:

$SKILL_DIR/scripts/google-docs.py check

This will check:

  • Python dependencies (google-auth, google-auth-oauthlib, google-api-python-client, keyring, pyyaml, markdown-it-py)
  • Authentication configuration
  • Connectivity to Google Docs API

If anything is missing, the check command will provide setup instructions.

Authentication

Google Docs uses OAuth 2.0 for authentication. For complete setup instructions, see:

  1. GCP Project Setup Guide - Create project, enable Docs API
  2. Google OAuth Setup Guide - Configure credentials

Quick Start

  1. Create ~/.config/agent-skills/google.yaml:

    oauth_client:
      client_id: your-client-id.apps.googleusercontent.com
      client_secret: your-client-secret
    
  2. Run $SKILL_DIR/scripts/google-docs.py check to trigger OAuth flow and verify setup.

On scope or authentication errors, see the OAuth troubleshooting guide.

Commands

See permissions.md for read/write classification of each command.

check

Verify configuration and connectivity.

$SKILL_DIR/scripts/google-docs.py check

This validates:

  • Python dependencies are installed
  • Authentication is configured
  • Can connect to Google Docs API
  • Creates a test document to verify write access

auth setup

Store OAuth 2.0 client credentials for custom OAuth flow.

$SKILL_DIR/scripts/google-docs.py auth setup \
  --client-id YOUR_CLIENT_ID \
  --client-secret YOUR_CLIENT_SECRET

Credentials are saved to ~/.config/agent-skills/google-docs.yaml.

Options:

  • --client-id - OAuth 2.0 client ID (required)
  • --client-secret - OAuth 2.0 client secret (required)

auth reset

Clear stored OAuth token. The next command that needs authentication will trigger re-authentication automatically.

$SKILL_DIR/scripts/google-docs.py auth reset

Use this when you encounter scope or authentication errors.

auth status

Show current OAuth token information without making API calls.

$SKILL_DIR/scripts/google-docs.py auth status

Displays: whether a token is stored, granted scopes, refresh token presence, token expiry, and client ID.

documents create

Create a new blank Google Doc.

$SKILL_DIR/scripts/google-docs.py documents create --title "My Document"

Options:

  • --title - Document title (required)

Example:

# Create a new document
$SKILL_DIR/scripts/google-docs.py documents create --title "Project Notes"

# Output:
# ✓ Document created successfully
#   Title: Project Notes
#   Document ID: 1abc...xyz
#   URL: https://docs.google.com/document/d/1abc...xyz/edit

documents get

Get document metadata and structure.

$SKILL_DIR/scripts/google-docs.py documents get DOCUMENT_ID

Arguments:

  • document_id - The Google Docs document ID

Example:

# Get document metadata
$SKILL_DIR/scripts/google-docs.py documents get 1abc...xyz

# Output:
# Title: Project Notes
# Document ID: 1abc...xyz
# Characters: 1234
# Revision ID: abc123

documents read

Read document content as plain text, markdown, or PDF.

$SKILL_DIR/scripts/google-docs.py documents read DOCUMENT_ID

Arguments:

  • document_id - The Google Docs document ID

Options:

  • --format - Output format: markdown (default, preserves tables and headings) or pdf
  • --output, -o - Output file path (used with pdf format)

Example:

# Read as markdown (default, preserves tables and headings)
$SKILL_DIR/scripts/google-docs.py documents read 1abc...xyz

# Export as PDF
$SKILL_DIR/scripts/google-docs.py documents read 1abc...xyz --format pdf --output document.pdf

# Output as markdown:
# # Heading
#
# This is a paragraph.
#
# | Column 1 | Column 2 |
# |----------|----------|
# | Value 1  | Value 2  |

Note: Markdown and PDF export use Google's native Drive API export. Markdown preserves tables, headings, formatting, and structure with high fidelity. Both require the drive.readonly scope.

documents import

Import a local markdown file as a natively formatted Google Doc. Uses Drive API HTML-to-Docs conversion for full markdown fidelity including tables, code blocks, headings, bold, italic, links, and lists.

$SKILL_DIR/scripts/google-docs.py documents import FILE_PATH [--title TITLE] [--document-id DOC_ID] [--folder-id ID]

Arguments:

  • file_path - Local path to a markdown file

Options:

  • --title - Document title (default: first H1 heading, or filename)
  • --document-id - Existing document ID to update (replaces content)
  • --folder-id - Parent folder ID for new documents
  • --no-format - Skip post-import formatting
  • --no-images - Skip embedding local images
  • --json - Output as JSON

Examples:

# Import a markdown file as a new Google Doc
$SKILL_DIR/scripts/google-docs.py documents import ./report.md --title "Monthly Report"

# Import using the first H1 heading as the title
$SKILL_DIR/scripts/google-docs.py documents import ./notes.md

# Update an existing document with new markdown content
$SKILL_DIR/scripts/google-docs.py documents import ./updated.md --document-id 1abc...xyz

# Import without post-import formatting
$SKILL_DIR/scripts/google-docs.py documents import ./raw.md --no-format

# Import without embedding images
$SKILL_DIR/scripts/google-docs.py documents import ./doc.md --no-images

Images: Local image references in markdown (![alt text](path/to/image.png)) are automatically embedded inline in the Google Doc at their original position. Paths are resolved relative to the markdown file's directory. URL-based images (![alt](https://...)) are not supported and will be omitted. Use --no-images to skip image processing.

Frontmatter: YAML frontmatter (--- delimited) is stripped from the markdown before import — it is not included in the Google Doc content. Supported frontmatter fields:

  • title — Document title (overridden by --title flag)
  • folder_id — Parent folder ID (overridden by --folder-id flag)
  • line_spacing — Line spacing percentage (default: 115)
  • space_below — Space below paragraphs in pt (default: 8)
  • pageless — Set to true for pageless mode
---
title: My Document
line_spacing: 130
space_below: 10
---

After formatting, a readability summary is printed showing heading, paragraph, and list item counts.

Note: Requires markdown-it-py Python library and the drive.file + documents scopes.

See also: For uploading files to Google Drive (non-markdown), sharing, organizing into folders, or exporting documents, use the google-drive skill.

content append

Append text to the end of a document.

$SKILL_DIR/scripts/google-docs.py content append DOCUMENT_ID --text "Additional content"

Arguments:

  • document_id - The Google Docs document ID

Options:

  • --text - Text to append (required)

Example:

# Append text
$SKILL_DIR/scripts/google-docs.py content append 1abc...xyz --text "Meeting notes from today..."

# Output:
# ✓ Text appended successfully

content insert

Insert text at a specific position in the document.

$SKILL_DIR/scripts/google-docs.py content insert DOCUMENT_ID --text "Insert this" --index 10

Arguments:

  • document_id - The Google Docs document ID

Options:

  • --text - Text to insert (required)
  • --index - Position to insert at, 0-based (required)

Example:

# Insert text at the beginning (index 1, after title)
$SKILL_DIR/scripts/google-docs.py content insert 1abc...xyz --text "Introduction\n\n" --index 1

# Output:
# ✓ Text inserted successfully

Note: Index 0 is before the document content. Index 1 is at the beginning of content.

content delete

Delete a range of content from the document.

$SKILL_DIR/scripts/google-docs.py content delete DOCUMENT_ID --start-index 10 --end-index 50

Arguments:

  • document_id - The Google Docs document ID

Options:

  • --start-index - Start position, inclusive (required)
  • --end-index - End position, exclusive (required)

Example:

# Delete characters 10-50
$SKILL_DIR/scripts/google-docs.py content delete 1abc...xyz --start-index 10 --end-index 50

# Output:
# ✓ Content deleted successfully

Warning: Be careful with indices. Deleting the wrong range can corrupt document structure.

content insert-after-anchor

Insert markdown-formatted content after a structural anchor (horizontal rule, heading, or bookmark) in a document. Handles text insertion, heading styles, bullet lists, bold formatting, and links in a single operation.

$SKILL_DIR/scripts/google-docs.py content insert-after-anchor DOCUMENT_ID \
  --anchor-type ANCHOR_TYPE --markdown "MARKDOWN_CONTENT"

Arguments:

  • document_id - The Google Docs document ID

Options:

  • --anchor-type - Type of anchor to find: horizontal_rule, heading, or bookmark (required)
  • --anchor-value - Anchor-specific value: heading text (for heading), bookmark ID (for bookmark), or occurrence number (for horizontal_rule, default 1)
  • --markdown - Markdown-formatted content to insert (required). Use \n for newlines.

Supported markdown:

SyntaxResult
## HeadingHeading (levels 1-6)
**text**Bold text
[text](url)Hyperlink
- itemBullet list
- itemNested bullet (indent 2 spaces per level)

Examples:

# Insert after the first horizontal rule
$SKILL_DIR/scripts/google-docs.py content insert-after-anchor 1abc...xyz \
  --anchor-type horizontal_rule \
  --markdown '## Status Update\n\n**Summary:**\n- Task completed\n  - Sub-task done\n- [Details](https://example.com)'

# Insert after a specific heading
$SKILL_DIR/scripts/google-docs.py content insert-after-anchor 1abc...xyz \
  --anchor-type heading \
  --anchor-value "Notes" \
  --markdown '- New note item\n- Another item'

# Insert after the second horizontal rule
$SKILL_DIR/scripts/google-docs.py content insert-after-anchor 1abc...xyz \
  --anchor-type horizontal_rule \
  --anchor-value 2 \
  --markdown '## New Section\n\nParagraph text here.'

formatting apply

Apply text formatting to a range of text.

$SKILL_DIR/scripts/google-docs.py formatting apply DOCUMENT_ID \
  --start-index 1 --end-index 20 --bold --italic

Arguments:

  • document_id - The Google Docs document ID

Options:

  • --start-index - Start position, inclusive (required)
  • --end-index - End position, exclusive (required)
  • --bold - Apply bold formatting
  • --italic - Apply italic formatting
  • --underline - Apply underline formatting
  • --font-size SIZE - Set font size in points

Example:

# Make title bold and larger
$SKILL_DIR/scripts/google-docs.py formatting apply 1abc...xyz \
  --start-index 1 --end-index 20 --bold --font-size 18

# Apply italic to a section
$SKILL_DIR/scripts/google-docs.py formatting apply 1abc...xyz \
  --start-index 50 --end-index 100 --italic

# Output:
# ✓ Formatting applied successfully

Examples

Create and populate a document

# Create a new document
$SKILL_DIR/scripts/google-docs.py documents create --title "Weekly Report"

# Add content
$SKILL_DIR/scripts/google-docs.py content append $DOC_ID --text "Weekly Report\n\n"
$SKILL_DIR/scripts/google-docs.py content append $DOC_ID --text "Summary: This week's accomplishments...\n"

# Format the title
$SKILL_DIR/scripts/google-docs.py formatting apply $DOC_ID --start-index 1 --end-index 14 --bold --font-size 18

# Read it back
$SKILL_DIR/scripts/google-docs.py documents read $DOC_ID

Read and extract content

# Get document info
$SKILL_DIR/scripts/google-docs.py documents get 1abc...xyz

# Extract plain text
$SKILL_DIR/scripts/google-docs.py documents read 1abc...xyz > document.txt

# Get document structure
$SKILL_DIR/scripts/google-docs.py documents get 1abc...xyz

Insert formatted content after an anchor

# Insert a formatted status update after a horizontal rule
$SKILL_DIR/scripts/google-docs.py content insert-after-anchor $DOC_ID \
  --anchor-type horizontal_rule \
  --markdown '## Weekly Update\n\n**Completed:**\n- Feature implementation\n  - Backend API\n  - Frontend UI\n- [Project board](https://example.com/board)'

Edit existing content

# Insert a new section
$SKILL_DIR/scripts/google-docs.py content insert 1abc...xyz \
  --text "\n\nNew Section\n" --index 100

# Format the new section header
$SKILL_DIR/scripts/google-docs.py formatting apply 1abc...xyz \
  --start-index 102 --end-index 113 --bold

# Append more content
$SKILL_DIR/scripts/google-docs.py content append 1abc...xyz \
  --text "Additional details about the new section..."

Error Handling

Authentication and scope errors are not retryable. If a command fails with an authentication error, insufficient scope error, or permission denied error (exit code 1), stop and inform the user. Do not retry or attempt to fix the issue autonomously — these errors require user interaction (browser-based OAuth consent). Point the user to the OAuth troubleshooting guide.

Retryable errors: Rate limiting (HTTP 429) and temporary server errors (HTTP 5xx) may succeed on retry after a brief wait. All other errors should be reported to the user.

Model Guidance

This skill makes API calls requiring structured input/output. A standard-capability model is recommended.

Troubleshooting

Cannot find document

Make sure you're using the correct document ID from the URL:

  • URL: https://docs.google.com/document/d/1abc...xyz/edit
  • Document ID: 1abc...xyz

Index errors when inserting/deleting

Use documents get to see the document structure and valid index ranges. Remember:

  • Index 0 is before any content
  • Index 1 is at the start of document body
  • The last index is the document length

API Reference

For advanced usage, see:

FAQ

What does the google-docs skill do?

Create and modify Google Docs documents. Read content, insert tables, apply heading styles, and manage formatting. Use when asked to edit a gdoc, write a Google document, update a doc, or format document content.

How do I install google-docs?

Run npx skills add https://github.com/odyssey4me/agent-skills --skill google-docs in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/google-docs/ (personal) or .claude/skills/google-docs/ (project).

Which AI agents can use google-docs?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is google-docs safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains google-docs?

It is published by odyssey4me in odyssey4me/agent-skills. It has 262 recorded installs.

More from odyssey4me/agent-skills

View all →

google-calendar

odyssey4me/agent-skills

Create, update, and organize Google Calendar events and schedules. Check availability, book time, and manage calendars. Use when asked to schedule a meeting, set up an appointment, book a call, check gcal, or manage calendar events.

google

odyssey4me/agent-skills

Google Workspace CLI for Gmail, Calendar, Drive, Docs, Sheets, and Slides using gogcli. Use when asked to search email, schedule meetings, manage files, edit documents, update spreadsheets, or create presentations.

gitlab

odyssey4me/agent-skills

Create and manage GitLab issues, merge requests, pipelines, and repositories using the glab CLI. Use when asked to open an MR, review a merge request, check CI/CD pipelines, list issues, or manage code review on GitLab.

google-drive

odyssey4me/agent-skills

Open the skill to read its SKILL.md instructions.

AI & Agents299 installs

gmail

odyssey4me/agent-skills

Send, search, and organize Gmail messages, drafts, and labels. Read full threads and get shareable Google Groups permalinks. Use when asked to compose an email, reply to mail, forward a message, search inbox, manage attachments, organize Gmail, read a thread, or find a Google Groups discussion link.

github

odyssey4me/agent-skills

Create and manage GitHub issues, pull requests, workflows, and repositories using the gh CLI. Use when asked to open a PR, merge a pull request, check repo actions, list issues, create a branch, or manage GitHub projects.

Popular docs & writing skills

View category →

grill-with-docs

mattpocock/skills

A relentless interview to sharpen a plan or design, which also creates docs (ADR's and glossary) as we go.

Docs & Writing1.2M installs

lark-markdown

open.feishu.cn

飞书 Markdown:查看、创建、上传、编辑和比较飞书中的原生 Markdown 文件。当用户要操作飞书 Markdown 文件,或比较其远端版本及本地草稿时使用。纯本地 Markdown 文件操作不触发本 skill。不负责将 Markdown 导入为飞书在线文档,也不负责文件搜索、权限、评论、移动、删除等云空间管理操作。

Docs & Writing778.7K installs

writing-beats

mattpocock/skills

Writing, exploit; assemble raw material into a journey of beats, grounding each term before a beat leans on it.

Docs & Writing490.7K installs

writing-shape

mattpocock/skills

Writing, exploit: shape raw material into an article, paragraph by paragraph.

Docs & Writing490.2K installs

writing-fragments

mattpocock/skills

Writing, explore: mine raw fragments, no structure yet.

Docs & Writing489.6K installs

writing-for-agents

mattpocock/skills

Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md.

Docs & Writing479.3K installs