google-docs — MCP server for Google Docs: setup and use
Lets your coding agent work with Google Docs: read, create, edit, delete and export files, authorized through OAuth2 or a Workspace service account.
claude mcp add --env GOOGLE_DOCS_OAUTH_CLIENT_ID=<GOOGLE_DOCS_OAUTH_CLIENT_ID> --env GOOGLE_DOCS_OAUTH_CLIENT_SECRET=<GOOGLE_DOCS_OAUTH_CLIENT_SECRET> --env GOOGLE_DOCS_OAUTH_REFRESH_TOKEN=<GOOGLE_DOCS_OAUTH_REFRESH_TOKEN> --env GOOGLE_DOCS_SERVICE_ACCOUNT_CLIENT_EMAIL=<GOOGLE_DOCS_SERVICE_ACCOUNT_CLIENT_EMAIL> --env GOOGLE_DOCS_SERVICE_ACCOUNT_PRIVATE_KEY=<GOOGLE_DOCS_SERVICE_ACCOUNT_PRIVATE_KEY> --transport stdio google-docs -- npx -y google-docs-workspace-mcp-serverWhat google-docs does
The server talks to Google Docs through the Docs and Drive APIs. An agent can pull a document's full body or only its heading outline, given an ID or a shareable link. It can start a new doc with seeded text, append to the end, insert at a chosen index, swap every occurrence of a string, or send raw documents.batchUpdate calls when you need structural changes. Deleting is available too: to Drive trash by default, permanently when you say so.
Export covers Markdown, HTML, plain text, PDF, DOCX, ODT, RTF and EPUB. Sharing is gated behind its own tool group.
Two auth paths. A personal @gmail.com account needs OAuth2 credentials of the Desktop app kind, created after you publish the consent screen, plus a refresh token from npx google-docs-workspace-mcp-server oauth-setup <client_id> <client_secret>. Inside Google Workspace, a service account with domain-wide delegation and the documents and drive scopes does the job. Leaving the consent screen unpublished caps the refresh token at seven days, so you redo the setup; editing tool access goes through GOOGLE_DOCS_ENABLED_TOOLGROUPS.
What it helps with
- pull a Google Doc's text or outline from a link
- create a doc and append a draft to it
- swap every occurrence of a string in a doc
- export a doc to Markdown or PDF
- give a teammate or group access to a doc
Example prompts for the agent
- Read the outline of the doc at this link and show me its structure
- Create a Google Doc with these release notes and export it to Markdown
- Replace every mention of the old product name in that document
How to install google-docs
Platform CLI
claude mcp add --env GOOGLE_DOCS_OAUTH_CLIENT_ID=<GOOGLE_DOCS_OAUTH_CLIENT_ID> --env GOOGLE_DOCS_OAUTH_CLIENT_SECRET=<GOOGLE_DOCS_OAUTH_CLIENT_SECRET> --env GOOGLE_DOCS_OAUTH_REFRESH_TOKEN=<GOOGLE_DOCS_OAUTH_REFRESH_TOKEN> --env GOOGLE_DOCS_SERVICE_ACCOUNT_CLIENT_EMAIL=<GOOGLE_DOCS_SERVICE_ACCOUNT_CLIENT_EMAIL> --env GOOGLE_DOCS_SERVICE_ACCOUNT_PRIVATE_KEY=<GOOGLE_DOCS_SERVICE_ACCOUNT_PRIVATE_KEY> --transport stdio google-docs -- npx -y google-docs-workspace-mcp-serverReplace <…> with your own values. 2 more environment variables are in the server README
Platform CLI
codex mcp add google-docs --env GOOGLE_DOCS_OAUTH_CLIENT_ID=<GOOGLE_DOCS_OAUTH_CLIENT_ID> --env GOOGLE_DOCS_OAUTH_CLIENT_SECRET=<GOOGLE_DOCS_OAUTH_CLIENT_SECRET> --env GOOGLE_DOCS_OAUTH_REFRESH_TOKEN=<GOOGLE_DOCS_OAUTH_REFRESH_TOKEN> --env GOOGLE_DOCS_SERVICE_ACCOUNT_CLIENT_EMAIL=<GOOGLE_DOCS_SERVICE_ACCOUNT_CLIENT_EMAIL> --env GOOGLE_DOCS_SERVICE_ACCOUNT_PRIVATE_KEY=<GOOGLE_DOCS_SERVICE_ACCOUNT_PRIVATE_KEY> -- npx -y google-docs-workspace-mcp-serverReplace <…> with your own values. 2 more environment variables are in the server README
Config file
{
"mcpServers": {
"google-docs": {
"command": "npx",
"args": [
"-y",
"google-docs-workspace-mcp-server"
],
"env": {
"GOOGLE_DOCS_OAUTH_CLIENT_ID": "<GOOGLE_DOCS_OAUTH_CLIENT_ID>",
"GOOGLE_DOCS_OAUTH_CLIENT_SECRET": "<GOOGLE_DOCS_OAUTH_CLIENT_SECRET>",
"GOOGLE_DOCS_OAUTH_REFRESH_TOKEN": "<GOOGLE_DOCS_OAUTH_REFRESH_TOKEN>",
"GOOGLE_DOCS_SERVICE_ACCOUNT_CLIENT_EMAIL": "<GOOGLE_DOCS_SERVICE_ACCOUNT_CLIENT_EMAIL>",
"GOOGLE_DOCS_SERVICE_ACCOUNT_PRIVATE_KEY": "<GOOGLE_DOCS_SERVICE_ACCOUNT_PRIVATE_KEY>"
}
}
}
}Replace <…> with your own values. 2 more environment variables are in the server README
Config file
{
"servers": {
"google-docs": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"google-docs-workspace-mcp-server"
],
"env": {
"GOOGLE_DOCS_OAUTH_CLIENT_ID": "<GOOGLE_DOCS_OAUTH_CLIENT_ID>",
"GOOGLE_DOCS_OAUTH_CLIENT_SECRET": "<GOOGLE_DOCS_OAUTH_CLIENT_SECRET>",
"GOOGLE_DOCS_OAUTH_REFRESH_TOKEN": "<GOOGLE_DOCS_OAUTH_REFRESH_TOKEN>",
"GOOGLE_DOCS_SERVICE_ACCOUNT_CLIENT_EMAIL": "<GOOGLE_DOCS_SERVICE_ACCOUNT_CLIENT_EMAIL>",
"GOOGLE_DOCS_SERVICE_ACCOUNT_PRIVATE_KEY": "<GOOGLE_DOCS_SERVICE_ACCOUNT_PRIVATE_KEY>"
}
}
}
}Replace <…> with your own values. 2 more environment variables are in the server README
Platform CLI
gemini mcp add -e GOOGLE_DOCS_OAUTH_CLIENT_ID=<GOOGLE_DOCS_OAUTH_CLIENT_ID> -e GOOGLE_DOCS_OAUTH_CLIENT_SECRET=<GOOGLE_DOCS_OAUTH_CLIENT_SECRET> -e GOOGLE_DOCS_OAUTH_REFRESH_TOKEN=<GOOGLE_DOCS_OAUTH_REFRESH_TOKEN> -e GOOGLE_DOCS_SERVICE_ACCOUNT_CLIENT_EMAIL=<GOOGLE_DOCS_SERVICE_ACCOUNT_CLIENT_EMAIL> -e GOOGLE_DOCS_SERVICE_ACCOUNT_PRIVATE_KEY=<GOOGLE_DOCS_SERVICE_ACCOUNT_PRIVATE_KEY> google-docs npx -y google-docs-workspace-mcp-serverReplace <…> with your own values. 2 more environment variables are in the server README
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about google-docs
How do I install google-docs in Claude Code?
Run `claude mcp add google-docs -e GOOGLE_DOCS_OAUTH_CLIENT_ID=<GOOGLE_DOCS_OAUTH_CLIENT_ID> -e GOOGLE_DOCS_OAUTH_CLIENT_SECRET=<GOOGLE_DOCS_OAUTH_CLIENT_SECRET> -e GOOGLE_DOCS_OAUTH_REFRESH_TOKEN=<GOOGLE_DOCS_OAUTH_REFRESH_TOKEN> -e GOOGLE_DOCS_SERVICE_ACCOUNT_PRIVATE_KEY=<GOOGLE_DOCS_SERVICE_ACCOUNT_PRIVATE_KEY> -- npx -y google-docs-workspace-mcp-server` with your own values filled in.
What does google-docs do?
It gives an agent read and write access to Google Docs: fetching, creating, editing, deleting and exporting documents, plus sharing. Under the hood it uses the Docs and Drive APIs.
OAuth2 or service account?
Pick OAuth2 with a refresh token for a personal @gmail.com account. Pick a service account with domain-wide delegation and the documents and drive scopes for a Google Workspace organization.