A Model Context Protocol server that enables AI assistants like Claude to read from, append to, and format text in Google Documents programmatically.
Connect Claude Desktop (or other MCP clients) to your Google Docs!
🔥 Check out 10 powerful tasks you can accomplish with this enhanced server!
This enhanced server uses the Model Context Protocol (MCP) and the fastmcp
library to provide comprehensive tools for reading, writing, formatting, and structuring Google Documents. It acts as a powerful bridge, allowing AI assistants like Claude to interact with your documents programmatically with advanced capabilities.
Features:
readGoogleDoc
(plain text, JSON structure, or markdown)appendToGoogleDoc
insertText
deleteRange
applyTextStyle
(bold, italic, colors, etc.)applyParagraphStyle
(alignment, spacing, etc.)formatMatchingText
(legacy support)insertTable
insertPageBreak
fixListFormatting
for automatic list detectionBefore you start, make sure you have:
Follow these steps carefully to get your own instance of the server running.
This server needs permission to talk to Google APIs on your behalf. You'll create special "keys" (credentials) that only your server will use.
https://www.googleapis.com/auth/documents
(Allows reading/writing docs)https://www.googleapis.com/auth/drive.file
(Allows access to specific files opened/created by the app)client_secret_....json
.credentials.json
.credentials.json
file like a password! Do not share it publicly, and never commit it to GitHub. Anyone with this file could potentially pretend to be your application (though they'd still need user consent to access data).git clone https://github.com/a-bonus/google-docs-mcp.git mcp-googledocs-server
cd mcp-googledocs-server
credentials.json
file you downloaded and renamed (from Step 1.6) directly into this mcp-googledocs-server
folder.Your server needs some helper libraries specified in the package.json
file.
mcp-googledocs-server
directory), run:
This will download and install all the necessary packages into anpm install
node_modules
folder.The server is written in TypeScript (.ts
), but we need to compile it into JavaScript (.js
) that Node.js can run directly.
This uses the TypeScript compiler (npm run build
tsc
) to create a dist
folder containing the compiled JavaScript files.Now you need to run the server once manually to grant it permission to access your Google account data. This will create a token.json
file that saves your permission grant.
node
:
node ./dist/server.js
https://accounts.google.com/...
URL.http://localhost
and show a "This site can't be reached" error. THIS IS NORMAL!http://localhost/?code=4/0Axxxxxxxxxxxxxx&scope=...
code=
and the &scope
part. This is your single-use authorization code.Ctrl+C
to stop it).token.json
in your mcp-googledocs-server
folder.token.json
file contains the key that allows the server to access your Google account without asking again. Protect it like a password. Do not commit it to GitHub. The included .gitignore
file should prevent this automatically.If you want to use this server with Claude Desktop, you need to tell Claude how to run it.
Find Your Absolute Path: You need the full path to the server code.
mcp-googledocs-server
directory.pwd
command (on macOS/Linux) or cd
(on Windows, just displays the path)./Users/yourname/projects/mcp-googledocs-server
or C:\Users\yourname\projects\mcp-googledocs-server
).Locate mcp_config.json
: Find Claude's configuration file:
~/Library/Application Support/Claude/mcp_config.json
(You might need to use Finder's "Go" -> "Go to Folder..." menu and paste ~/Library/Application Support/Claude/
)%APPDATA%\Claude\mcp_config.json
(Paste %APPDATA%\Claude
into File Explorer's address bar)~/.config/Claude/mcp_config.json
Claude
folder or mcp_config.json
file doesn't exist, create them.Edit mcp_config.json
: Open the file in a text editor. Add or modify the mcpServers
section like this, replacing /PATH/TO/YOUR/CLONED/REPO
with the actual absolute path you copied in Step 6.1:
{ "mcpServers": { "google-docs-mcp": { "command": "node", "args": [ "/PATH/TO/YOUR/CLONED/REPO/mcp-googledocs-server/dist/server.js" ], "env": {} } // Add commas here if you have other servers defined } // Other Claude settings might be here }
"args"
is correct and absolute!mcpServers
object. Ensure the JSON is valid (check commas!).Save mcp_config.json
.
Restart Claude Desktop: Close Claude completely and reopen it.
Once configured, you should be able to use the tools in your chats with Claude:
google-docs-mcp
server to read the document with ID YOUR_GOOGLE_DOC_ID
."YOUR_GOOGLE_DOC_ID
?"YOUR_GOOGLE_DOC_ID
using the google-docs-mcp
tool."applyTextStyle
to make the text 'Important Section' bold and red (#FF0000) in document YOUR_GOOGLE_DOC_ID
."applyParagraphStyle
to center-align the paragraph containing 'Title Here' in document YOUR_GOOGLE_DOC_ID
."YOUR_GOOGLE_DOC_ID
using the insertTable
tool."formatMatchingText
to find the second instance of 'Project Alpha' and make it blue (#0000FF) in doc YOUR_GOOGLE_DOC_ID
."Remember to replace YOUR_GOOGLE_DOC_ID
with the actual ID from a Google Doc's URL (the long string between /d/
and /edit
).
Claude will automatically launch your server in the background when needed using the command you provided. You do not need to run node ./dist/server.js
manually anymore.
.gitignore
: This repository includes a .gitignore
file which should prevent you from accidentally committing your sensitive credentials.json
and token.json
files. Do not remove these lines from .gitignore
.token.json
) directly in the project folder for simplicity during setup. In production or more security-sensitive environments, consider storing this token more securely, such as using system keychains, encrypted files, or dedicated secret management services.mcp_config.json
.npm run build
successfully and the dist
folder exists.mcp_config.json
manually in your terminal: node /PATH/TO/YOUR/CLONED/REPO/mcp-googledocs-server/dist/server.js
. Look for any errors printed.console.log
status messages in the server code were changed to console.error
.credentials.json
file is correctly placed in the project root.This project is licensed under the MIT License - see the LICENSE
file for details. (Note: You should add a LICENSE
file containing the MIT License text to your repository).
Discover shared experiences
Shared threads will appear here, showcasing real-world applications and insights from the community. Check back soon for updates!