Generic Google Workspace MCP Server
Allows creating Gmail drafts and sending emails programmatically.
Allows appending content to existing Google Docs documents.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Generic Google Workspace MCP ServerDraft an email to jane@example.com about the project update"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Generic Google Workspace MCP Server
A reusable Model Context Protocol (MCP) server that exposes selected Google Workspace capabilities to any MCP-compatible AI agent.
Features
Gmail: create drafts and send emails
Google Docs: append content to existing documents
Agent-agnostic: works with Cursor, Claude Desktop, or any MCP client
Secure: OAuth managed by the server; no tokens in tool inputs
Structured responses: consistent success/error envelopes
Related MCP server: MCP Google Server
Architecture
See docs/architecture.md for the full design. The server uses a layered architecture:
MCP Layer → Validation → Services → Auth / Integrations → Google APIsSupported MCP Tools
Tool | Side effect | Description |
| No | Create a Gmail draft without sending |
| Yes | Send an email immediately |
| Yes | Append text to the end of a Google Doc |
Prerequisites
Node.js 20+ (required by MCP SDK v2)
A Google Cloud project with Gmail API and Google Docs API enabled
OAuth 2.0 credentials (Desktop or Web application)
Google Cloud Setup
Create a project in Google Cloud Console.
Enable Gmail API and Google Docs API.
Configure the OAuth consent screen (External or Internal).
Create OAuth 2.0 credentials:
Application type: Desktop app (for local dev) or Web application
Authorized redirect URI:
http://localhost:3000/oauth/callback(or your chosen URI)
Download the client ID and client secret.
Required OAuth Scopes
Scope | Purpose |
| Create drafts and send email |
| Append content to Google Docs |
The documents scope is sensitive — it allows editing any Doc the authenticated user can access. This is required because agents may append to arbitrary document IDs supplied by the user.
Local Setup
git clone <repo-url>
cd mcp-server-4
npm install
cp .env.example .env
# Edit .env with your Google OAuth credentialsAuthenticate
Run the OAuth flow to store tokens locally:
# Option 1: Manual code entry
npm run auth
# Option 2: Local callback server (opens browser, captures redirect)
npm run auth -- --callback-serverTokens are saved to GOOGLE_TOKEN_STORE_PATH (default: ./tokens.json).
Run the Server
# Development (stdio)
npm run dev
# Production build
npm run build
npm startEnvironment Variables
Variable | Required | Default | Description |
| Yes | — | OAuth client ID |
| Yes | — | OAuth client secret |
| Yes | — | OAuth redirect URI |
| No |
| Token storage path |
| No |
|
|
| No |
| HTTP transport host |
| No |
| HTTP transport port |
| No |
|
|
| No |
| Max email body size |
| No |
| Max doc append size |
MCP Client Configuration
Cursor
Add to your Cursor MCP settings (see examples/cursor-mcp-config.json):
{
"mcpServers": {
"google-workspace": {
"command": "node",
"args": ["/absolute/path/to/mcp-server-4/dist/index.js"],
"env": {
"GOOGLE_CLIENT_ID": "your-client-id",
"GOOGLE_CLIENT_SECRET": "your-client-secret",
"GOOGLE_REDIRECT_URI": "http://localhost:3000/oauth/callback",
"GOOGLE_TOKEN_STORE_PATH": "/absolute/path/to/tokens.json",
"MCP_TRANSPORT": "stdio"
}
}
}
}Build first with npm run build, or use tsx for development:
"command": "npx",
"args": ["tsx", "/absolute/path/to/mcp-server-4/src/index.ts"]Example Tool Calls
Create a draft
{
"to": ["user@example.com"],
"subject": "Project update",
"body": "Hi team,\n\nHere is the latest update...",
"bodyType": "text"
}Send an email
{
"to": ["user@example.com"],
"cc": ["manager@example.com"],
"subject": "Project update",
"body": "Hi team,\n\nHere is the latest update...",
"bodyType": "text"
}Append to a Google Doc
{
"documentId": "1AbCdEf...",
"content": "\n\n## Meeting Notes\n- Decision 1\n- Decision 2"
}Optional: "tabId": "..." targets a specific tab; "ensureLeadingNewline": true prepends a newline.
Testing
# Unit tests
npm test
# Integration tests (opt-in, requires real Google account)
RUN_INTEGRATION_TESTS=1 npm run test:integrationDocker
docker build -t google-workspace-mcp .
docker run -it --env-file .env -v $(pwd)/tokens.json:/app/data/tokens.json google-workspace-mcpSecurity Considerations
Never commit
.envortokens.json— both are gitignoredOAuth tokens are never exposed in MCP tool inputs or outputs
Email bodies and document content are not logged
Use human confirmation before high-impact email sends when appropriate
For production, replace file-based token storage with a secret manager
Troubleshooting
Issue | Solution |
| Run |
| Re-authenticate after adding scopes in Google Cloud |
| Ensure the Google account has edit access to the document |
Server won't start | Verify all required env vars are set; check Node.js ≥ 20 |
License
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server connecting AI agents to 100+ apps (Gmail, Slack, Notion, GitHub) via one-click OAuth.
Email infrastructure for AI agents — send, receive, search, and reply to email over MCP.
Multiple Gmail accounts, editable Google Sheets & Docs for AI agents. Deny-by-default access rules.
Permissioned access to Gmail, Drive and Calendar via the user's own Google account
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to send Gmail emails, create drafts, and append content to Google Docs through MCP tools. Provides secure OAuth-based integration with Google Workspace.239 npmMIT
- FlicenseNot gradedqualityCmaintenanceEnables MCP-compatible AI agents to draft and send Gmail emails and append content to Google Docs without needing to understand Google's APIs.-
- AlicenseAqualityCmaintenanceEnables MCP-compatible AI agents to create Gmail drafts, send Gmail email, and append text to Google Docs while keeping OAuth tokens inside the server.321 npmMIT
- AlicenseNot gradedqualityCmaintenanceEnables MCP-compatible AI agents to create and send Gmail messages and append text to existing Google Docs through OAuth-authenticated tools.1,069 npmMIT