An MCP (Model Context Protocol) server that enables AI assistants to interact with your Google Workspace, specifically Gmail and Google Docs.
This server provides tools that allow AI agents to safely construct drafts, send emails, and append formatted content to Google Docs on your behalf.
- Node.js 20+
- A Google Cloud project with the following APIs enabled:
- Gmail API
- Google Docs API
- OAuth 2.0 Credentials (Desktop application)
- Create a Google Cloud Project: Go to the Google Cloud Console and create a new project.
- Enable APIs: Navigate to "APIs & Services" > "Library" and enable:
- Gmail API
- Google Docs API
- Configure OAuth Consent Screen:
- Choose "External" (or "Internal" if you have a Google Workspace org).
- Add the following scopes:
https://www.googleapis.com/auth/gmail.composehttps://www.googleapis.com/auth/documents
- Create Credentials:
- Go to "Credentials" > "Create Credentials" > "OAuth client ID"
- Application type: "Desktop app"
- Download the JSON file and save it as
credentials.jsonin the root of this project.
npm installCreate a .env file in the root directory:
# OAuth Credentials (Alternative to credentials.json file)
# GOOGLE_CLIENT_ID=your-client-id
# GOOGLE_CLIENT_SECRET=your-client-secret
# GOOGLE_REDIRECT_URI=http://localhost:3000/oauth2callback
# MCP Configuration
MCP_SERVER_NAME=google-workspace-mcp
MCP_SERVER_VERSION=1.0.0
MCP_TRANSPORT=stdio
# Logging
LOG_LEVEL=info
# Storage
TOKEN_STORE_LOCATION=tokens.jsonBefore running the server, you need to authorize it to act on your behalf. Run the interactive authentication script:
npm run authFollow the prompts to click the link, authorize the app, and paste the authorization code back into the terminal. This will create a tokens.json file.
"Access blocked: App has not completed the Google verification process"
If you see this Error 403 access_denied, it means your Google Cloud project's OAuth Consent Screen is in "Testing" mode, and the email you are trying to log in with is not added as a test user.
Fix: Go to your Google Cloud Console - OAuth Consent Screen. Scroll down to "Test users", click "+ Add Users", and add the email address you are trying to authenticate with.
"Google hasn't verified this app" Warning This is normal for personal projects in "Testing" mode. Fix: Simply click "Advanced" and then click "Go to [Your App Name] (unsafe)" to proceed with authentication.
Start the server using stdio transport (standard for most MCP clients like Cursor/Antigravity):
npm run build
npm run startFor development:
npm run devCreates a draft email in your Gmail account.
- Parameters:
to(array of strings),cc(optional),bcc(optional),subject(string),body(string - HTML support).
Sends an email directly from your Gmail account.
- Parameters:
to(array of strings),cc(optional),bcc(optional),subject(string),body(string - HTML support).
Appends formatted content (headings, paragraphs, lists) to the end of an existing Google Doc.
- Parameters:
documentId: The ID from the Google Doc URL (e.g.docs.google.com/document/d/{documentId}/edit)content: An array of block objects (heading,paragraph,bulletList,numberedList).
- Build:
npm run build - Typecheck:
npm run typecheck - Lint:
npm run lint
Build the image:
docker build -t google-workspace-mcp .Run the container (mounting the credentials and tokens files):
docker run -i \
-v $(pwd)/credentials.json:/app/credentials.json \
-v $(pwd)/tokens.json:/app/tokens.json \
-e GOOGLE_APPLICATION_CREDENTIALS=/app/credentials.json \
google-workspace-mcp- Never commit
credentials.json,tokens.json, or.envto version control. - The built-in logger redacts properties named
token,secret,password,body, andcontent. - Tokens are stored locally on your machine in the file specified by
TOKEN_STORE_LOCATION.