Google Workspace MCP Server
Allows creating Gmail drafts and sending email through the Gmail API, with support for composing messages and triggering external email sends.
Allows appending text to the end of a Google Doc's body by document ID using the Google Docs API.
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., "@Google Workspace MCP Server create a Gmail draft to my manager 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.
Google Workspace MCP Server
Generic Model Context Protocol server that lets any MCP-compatible AI agent:
Create Gmail drafts (
gmail_create_draft)Send Gmail email (
gmail_send_email) — external side effectAppend text to a Google Doc (
google_docs_append_content)
Google OAuth tokens stay inside this server. Agents never see client secrets or access tokens.
See Docs/architecture.md and Docs/problemStatement.md.
Requirements
Node.js 20+
A Google Cloud project with Gmail API and Google Docs API enabled
OAuth 2.0 Desktop or Web client credentials
Related MCP server: MCP Google Server
Setup
1. Install
npm install2. Google Cloud
Create a project in Google Cloud Console.
Enable Gmail API and Google Docs API.
Configure the OAuth consent screen (add your Google account as a test user if the app is in testing).
Create OAuth client credentials (Desktop app is simplest for local use).
Add authorized redirect URI:
http://localhost:3000/oauth2callback(or matchGOOGLE_REDIRECT_URI).
3. Environment
cp .env.example .envFill in:
GOOGLE_CLIENT_ID=...
GOOGLE_CLIENT_SECRET=...
GOOGLE_REDIRECT_URI=http://localhost:3000/oauth2callback
GOOGLE_TOKEN_STORAGE=.tokens/google-token.json
LOG_LEVEL=info4. Authorize once
npm run authThis opens a browser for Google consent and writes tokens to GOOGLE_TOKEN_STORAGE.
Default scopes:
https://www.googleapis.com/auth/gmail.composehttps://www.googleapis.com/auth/documents
(documents is used so agents can append by document ID. Override with GOOGLE_SCOPES if needed.)
5. Run
npm run build
npm startDevelopment (TypeScript directly):
npm run devCursor / MCP client config
Example Cursor MCP settings (stdio):
{
"mcpServers": {
"google-workspace": {
"command": "node",
"args": ["C:/Users/dhruv/MCP Server 1/dist/server.js"],
"env": {
"GOOGLE_CLIENT_ID": "your-client-id",
"GOOGLE_CLIENT_SECRET": "your-client-secret",
"GOOGLE_REDIRECT_URI": "http://localhost:3000/oauth2callback",
"GOOGLE_TOKEN_STORAGE": "C:/Users/dhruv/MCP Server 1/.tokens/google-token.json",
"LOG_LEVEL": "info"
}
}
}
}Or point command at npx tsx and args at src/server.ts during development.
Tools
Tool | Purpose |
| Create a draft (does not send) |
| Send email immediately (not idempotent in v1) |
| Append text at end of doc body by |
Structured responses look like:
{ "success": true, "draft_id": "...", "message_id": "...", "thread_id": "...", "provider": "gmail" }or:
{ "success": false, "error": { "code": "VALIDATION_ERROR", "message": "..." } }Deploy on Railway
Remote hosting uses Streamable HTTP (not stdio). Full checklist: Docs/deployment-plan.md.
Summary:
Build/start:
npm run buildthennpm run start:http(Railway Start Command).Set Railway variables:
GOOGLE_CLIENT_ID,GOOGLE_CLIENT_SECRET,GOOGLE_REDIRECT_URI(https://<domain>/oauth2callback),MCP_API_KEY, and eitherGOOGLE_REFRESH_TOKENor a Volume +GOOGLE_TOKEN_STORAGE=/data/token.json.Health check path:
/health.First Google login: temporarily set
ENABLE_OAUTH_SETUP=true, visit/oauth/start, then disable setup and prefer storing the refresh token inGOOGLE_REFRESH_TOKEN.Point MCP clients at
https://<domain>/mcpwithAuthorization: Bearer <MCP_API_KEY>.
Local HTTP smoke test:
MCP_API_KEY=dev-secret npm run dev:http
curl http://127.0.0.1:3000/healthScripts
Command | Description |
| OAuth browser login + token save |
| Run stdio server via tsx |
| Run Streamable HTTP server via tsx |
| Compile to |
| Run compiled stdio server |
| Run compiled HTTP server (Railway) |
| Unit tests (mocked Google APIs) |
| TypeScript check |
Project layout
src/
server.ts # MCP stdio bootstrap
http.ts # Streamable HTTP + /health + bearer auth
app.ts # Shared createAppServer / providers
config/ # env-driven configuration
mcp/tools/ # MCP tool handlers
mcp/schemas/ # Zod input schemas for tools
providers/google/ # OAuth, Gmail, Docs
validation/ # email/doc validation
errors/ # normalized error codes
logging/ # structured stderr logging (redacted)
scripts/auth.ts # local OAuth helper
tests/unit/ # vitest unit testsSecurity notes
Never commit
.envor token files.Logs go to stderr (stdout is reserved for MCP) and redact tokens/secrets/bodies.
gmail_send_emailis an external side effect; clients should confirm with the user when appropriate.
Available Tools
3 toolsgmail_create_draftCreate Gmail draftA
Create a draft email in the authenticated user's Gmail account without sending it.
When to use:
The agent should prepare an email for later review or sending.
Prefer this over gmail_send_email when the user has not confirmed sending.
Required parameters: to (non-empty array of valid emails), subject, body. Optional: cc, bcc, is_html (default false).
Side effects: Creates a Gmail draft only. Does not send the email.
Success: Returns draft_id, message_id, thread_id, and provider "gmail". Common failures: VALIDATION_ERROR (bad emails/missing fields), AUTHENTICATION_REQUIRED, AUTHORIZATION_DENIED, GOOGLE_API_ERROR.
Inputs: to (required), body (required), subject (required), cc, +3 more.
gmail_send_emailSend Gmail emailADestructive
Send an email through Gmail on behalf of the authenticated Google account.
IMPORTANT SIDE EFFECT: This tool actually sends an email. It is not a draft. MCP clients/agents should obtain user confirmation when appropriate before calling this tool. The server will not silently convert a send into a draft.
When to use:
The user explicitly wants the email delivered now.
Do not use this to "prepare" an email; use gmail_create_draft instead.
Required parameters: to (non-empty array of valid emails), subject, body. Optional: cc, bcc, is_html (default false), idempotency_key (reserved; not enforced in v1 — sends are not inherently idempotent).
Success: Returns message_id, thread_id, and provider "gmail". Common failures: VALIDATION_ERROR, AUTHENTICATION_REQUIRED, AUTHORIZATION_DENIED, RATE_LIMITED, GOOGLE_API_ERROR, NETWORK_ERROR.
Recipient addresses and content are not silently modified.
Inputs: to (required), body (required), subject (required), cc, +3 more.
google_docs_append_contentAppend to Google DocA
Append plain text to the end of an existing Google Doc.
When to use:
Add content to a known document without calculating Google Docs insertion indexes.
Pass the document ID only (not a full Docs URL).
Required parameters: document_id, content (non-empty). Optional: add_newline_before (default true), add_newline_after (default false).
Side effects: Mutates the document body by inserting text at the end of the body segment. Uses revision WriteControl so concurrent edits are detected rather than applied blindly.
Success: Returns document_id, appended_characters, and provider "google_docs". Common failures: VALIDATION_ERROR (empty content), RESOURCE_NOT_FOUND, AUTHENTICATION_REQUIRED, AUTHORIZATION_DENIED, GOOGLE_API_ERROR (including stale revision).
Inputs: content (required), document_id (required), add_newline_after, add_newline_before.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
The three tools target clearly distinct actions: creating a Gmail draft, sending a Gmail email, and appending to a Google Doc. The descriptions explicitly contrast draft vs. send and provide strong guidance on when to use each, eliminating misselection risk.
All tool names use consistent snake_case with a service prefix + verb + noun pattern: gmail_create_draft, gmail_send_email, google_docs_append_content. The only minor deviation is the prefix style (gmail vs google_docs), but this is still readable and predictable.
Three tools is very thin for a server labeled 'Google Workspace,' which implies broad coverage of Gmail, Docs, Drive, Calendar, and more. While the individual tools are well-scoped, the count is mismatched to the apparent breadth of the stated purpose.
The surface covers only Gmail draft/send and Docs append, with no read, list, search, update, or delete operations for those services, and no other Workspace products at all. This leaves significant gaps that would cause agent dead ends for common Workspace tasks.
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.
Connect any AI agent to 1,000+ apps and 27,000+ actions through one remote MCP server (OAuth).
Gmail, Outlook, Drive, OneDrive and calendars for AI agents. Many accounts, one endpoint, audit log.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables MCP-compatible AI agents to create Gmail drafts, send emails, and append content to Google Docs with OAuth-secured authentication.22 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 AI agents to create and send Gmail messages and append content to Google Docs through the MCP protocol.330 npmISC
- AlicenseNot gradedqualityCmaintenanceEnables MCP-compatible AI agents to create and send Gmail messages and append text to existing Google Docs through OAuth-authenticated tools.1,276 npmMIT