Generic Google Workspace MCP Server
Allows creating Gmail drafts and sending emails programmatically.
Allows appending content to existing Google Docs documents.
Click on "Install 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 Workspace 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 installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- FlicenseNot gradedqualityCmaintenanceEnables AI agents to send emails and append content to Google Docs using Gmail and Google Docs APIs.
- AlicenseBqualityCmaintenanceExposes Gmail (send/draft) and Google Docs (append) capabilities as tools for any MCP-compliant agent.347ISC
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to send emails, create drafts in Gmail, and append content to Google Docs via standardized MCP tools.47ISC
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to send emails via Gmail and append content to Google Docs.225MIT
Related MCP Connectors
Phone, SMS & email for AI agents — one remote MCP endpoint, OAuth login, zero install.
Manage Gmail end-to-end: search, read, send, draft, label, and organize threads. Automate workflow…
Hosted Google Calendar MCP server for AI agents. No self-hosting or Google Cloud setup.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/saksham20189575/mcp-server-4'
If you have feedback or need assistance with the MCP directory API, please join our Discord server