MCP Google Workspace Server
Provides tools for creating email drafts and sending emails via Gmail, with support for recipients, subject, body, and CC.
Allows appending content to Google Docs documents by document ID.
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., "@MCP Google Workspace Server Send an email to my team about the project timeline."
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.
MCP Google Workspace Server
A production-ready, generic MCP (Model Context Protocol) server that provides AI agents with secure, reusable tools for interacting with Gmail and Google Docs.
Any MCP-compatible AI agent (Claude Desktop, Cursor, Windsurf, etc.) can connect to this server and use Google Workspace capabilities without needing to implement Google API integrations themselves.
Architecture
AI Agent (Claude, Cursor, etc.)
│
│ MCP Protocol (stdio)
▼
Generic MCP Server
├── gmail_create_draft
├── gmail_send_email
└── google_docs_append_content
│
▼
Google APIs (HTTPS)
├── Gmail API
└── Google Docs APIDesign priority: Security → Genericity → Simplicity → Extensibility → Reliability
See docs/architecture.md for full architectural details.
Related MCP server: Google Services MCP Server
Available MCP Tools
Tool | Description | Side Effect |
| Creates an email draft in Gmail | Saved draft only |
| Sends an email via Gmail | Permanent — irreversible |
| Appends text to end of a Google Doc | Document edit |
Prerequisites
Node.js 18 or later
A Google Cloud project with the following APIs enabled:
OAuth 2.0 credentials (see setup below)
Google Cloud Setup
1. Create a Google Cloud Project
Go to the Google Cloud Console
Create a new project or select an existing one
2. Enable Required APIs
Enable the following APIs in your project:
Gmail API — for email draft creation and sending
Google Docs API — for document content appending
3. Configure OAuth 2.0
Go to APIs & Services → Credentials
Click Create Credentials → OAuth client ID
Select Desktop application as the application type
Add
http://localhost:3000/oauth/callbackas an authorized redirect URIDownload the credentials JSON and note your Client ID and Client Secret
4. Required OAuth Scopes
Scope | Purpose |
| Create drafts and send email |
| Read and write Google Docs |
Installation
# Clone the repository
git clone https://github.com/Daminigit/MCP-server-for-pulse-detector.git
cd MCP-server-for-pulse-detector
# Install dependencies
npm install
# Copy and configure environment variables
cp .env.example .envEnvironment Variables
Edit .env with your credentials:
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
GOOGLE_REDIRECT_URI=http://localhost:3000/oauth/callback
GOOGLE_TOKEN_STORAGE=.tokens/google-token.json
MCP_SERVER_PORT=3000
MCP_SERVER_HOST=localhost
LOG_LEVEL=info⚠️ Never commit
.envto Git. It is already listed in.gitignore.
Authentication (One-Time Setup)
Before starting the server, you must complete a one-time OAuth flow to authorize the application:
npm run authThis will:
Print a Google OAuth consent URL
Open it in your browser and grant the requested permissions
Paste the authorization code back into the terminal
Save the tokens to
GOOGLE_TOKEN_STORAGE
After this step, the server can authenticate all subsequent API calls automatically, including token refresh.
Running the Server
Development
npm run devProduction
npm run build
npm startConnecting an MCP-Compatible AI Agent
Claude Desktop
Add the following to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"google-workspace": {
"command": "node",
"args": ["/absolute/path/to/MCP-server-for-pulse-detector/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_STORAGE": "/absolute/path/to/.tokens/google-token.json"
}
}
}
}Using tsx (Development)
{
"mcpServers": {
"google-workspace": {
"command": "npx",
"args": ["tsx", "/absolute/path/to/MCP-server-for-pulse-detector/src/index.ts"]
}
}
}Example Tool Calls
Create an Email Draft
{
"tool": "gmail_create_draft",
"arguments": {
"to": ["recipient@example.com"],
"subject": "Project Update",
"body": "Here is the latest update on the project.",
"cc": ["manager@example.com"]
}
}Response:
{
"success": true,
"draft_id": "r1234567890",
"message": "Email draft created successfully."
}Send an Email
{
"tool": "gmail_send_email",
"arguments": {
"to": ["recipient@example.com"],
"subject": "Meeting Confirmed",
"body": "The meeting is confirmed for tomorrow at 10 AM."
}
}Append to a Google Doc
{
"tool": "google_docs_append_content",
"arguments": {
"document_id": "1AbCdEfGhIjKlMnOpQrStUvWxYz",
"content": "This is additional content generated by the AI agent."
}
}Testing
# Run all unit tests
npm test
# Run with coverage report
npm run test:coverageTests use mocked Google API clients — no real API calls are made during testing.
Security Considerations
OAuth tokens are never logged — pino is configured to redact all token fields automatically.
Tokens are never sent to the AI agent — they are managed entirely within the service layer.
Client credentials are loaded from environment variables only — never hard-coded.
The
.tokens/directory is gitignored — tokens are never committed to source control.Least-privilege OAuth scopes — only
gmail.composeanddocumentsare requested.Input validation occurs before any API call is made.
Error messages are sanitized — no tokens or secrets appear in error payloads.
Troubleshooting
AUTHENTICATION_REQUIRED error
Run npm run auth to complete the OAuth flow and generate tokens.
DOCUMENT_NOT_FOUND error
Ensure the document ID is correct (from the Google Doc URL) and the authenticated Google account has access to the document.
PERMISSION_DENIED error
Check that the required OAuth scopes were granted during the auth flow. Re-run npm run auth and grant all requested permissions.
Token file exists but auth still fails
Delete .tokens/google-token.json and re-run npm run auth to obtain fresh tokens.
TypeScript build errors
npm run lint # Check for type errors without buildingProject Structure
src/
├── server/ # MCP server bootstrap & tool registration
├── tools/
│ ├── gmail/ # gmail_create_draft, gmail_send_email handlers
│ └── google-docs/ # google_docs_append_content handler
├── services/ # Google API clients (Gmail, Docs, Auth)
├── utils/ # Validation, error handling, logging
├── config/ # Environment variable loader
└── scripts/ # OAuth setup script (auth.ts)
tests/ # Unit tests with mocked Google APIs
docs/ # Architecture and problem statementAvailable Tools
3 toolsgmail_create_draftA
Creates an email draft in the authenticated user's Gmail account. Use this tool when you want to prepare an email for review before sending. This tool does NOT send the email — the draft is only saved to Gmail Drafts. To send an email, use the gmail_send_email tool instead.
Inputs: to (required), body (required), subject (required), cc, +2 more.
gmail_send_emailA
Sends an email immediately via the authenticated Gmail account. Use this tool only when the user has explicitly confirmed they want to send the email. WARNING: This action is PERMANENT — the email will be delivered immediately and cannot be recalled. To create a draft for review instead, use gmail_create_draft.
Inputs: to (required), body (required), subject (required), cc, +2 more.
google_docs_append_contentA
Appends plain text content to the end of an existing Google Document. Use this tool to add new content at the bottom of a Google Doc without modifying existing content. The document ID can be found in the Google Doc URL: docs.google.com/document/d/<DOCUMENT_ID>/edit Existing document content is never overwritten or deleted.
Inputs: content (required), document_id (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool targets a distinct action and resource: Gmail draft creation, Gmail sending, and Docs appending. The draft/send distinction is explicitly explained in both descriptions, so there is no real ambiguity.
All tool names follow a consistent snake_case service_verb_noun pattern: gmail_create_draft, gmail_send_email, google_docs_append_content. The naming makes the target service and action predictable.
Three tools is on the thin side for a server claiming to cover Google Workspace. The scope is limited to outbound Gmail actions and one Docs mutation, which feels under-scoped for the stated domain.
The tool surface is severely incomplete for Google Workspace: there is no way to read or search Gmail, create or update Google Docs, or access Calendar, Drive, Sheets, or other core Workspace services. It only supports writing outbound email and appending to existing docs, leaving agents unable to perform basic lifecycle operations.
Maintenance
Related MCP Connectors
Email infrastructure for AI agents — send, receive, search, and reply to email over MCP.
MCP server connecting AI agents to 100+ apps (Gmail, Slack, Notion, GitHub) via one-click OAuth.
Multiple Gmail accounts, editable Google Sheets & Docs for AI agents. Deny-by-default access rules.
Email for AI agents: send, receive with a safety verdict, reply and approve, as MCP tools.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to send emails, create drafts in Gmail, and append content to Google Docs via standardized MCP tools.35 npmISC
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to send and draft Gmail emails and append content to Google Docs through standardized MCP tools.12 npmMIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to draft and send Gmail emails and append content to Google Docs through MCP tools.35 npmISC
- 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.-