Generic Gmail & Google Docs MCP Server
Allows creating email drafts and sending emails through Gmail, with support for to, cc, and bcc recipients.
Allows appending content to an existing Google Doc using the document ID.
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 Gmail & Google Docs MCP ServerDraft an email to John 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 Gmail & Google Docs MCP Server
Standalone Model Context Protocol server that exposes reusable Gmail and Google Docs tools. It is an integration layer, not an AI agent: it does not generate content, contain prompts, or depend on Cursor, Claude Desktop, or any other host.
Compatible clients:
Cursor — stdio
Claude Desktop — stdio
Custom agents — stdio or Streamable HTTP
Remote orchestrators — Streamable HTTP
See docs/problemStatement.md and docs/architecture.md.
Architecture
MCP Layer (stdio / Streamable HTTP)
↓
Tool Layer (create_email_draft, send_email, append_to_google_doc)
↓
Service Layer (validate → call → map)
↓
Google API Layer (Gmail / Docs clients)
↓
Authentication Layer (OAuth refresh token)Tool Handler → CredentialProvider → TokenStore
↓ ↓
Google OAuth Client (refresh) .env / Secret ManagerRelated MCP server: Google Workspace MCP Server
Supported MCP tools
Tool | Purpose |
| Create a Gmail draft without sending |
| Send an email through Gmail |
| Append content to an existing Google Doc |
Each tool returns a structured envelope:
{ "success": true, "message": "...", "...": "..." }or
{ "success": false, "error": { "code": "INVALID_EMAIL", "message": "..." } }Error codes: VALIDATION_ERROR, INVALID_EMAIL, DOCUMENT_NOT_FOUND, AUTHENTICATION_FAILED, GOOGLE_API_ERROR, UNKNOWN_TOOL.
Prerequisites
Node.js 20+
A Google Cloud project with Gmail API and Google Docs API enabled
An OAuth 2.0 client (Desktop or Web) whose redirect URI matches
GOOGLE_REDIRECT_URI
Google Cloud project setup
Open Google Cloud Console.
Create or select a project.
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 credentials (Desktop app is simplest for local use).
Set the authorized redirect URI to
http://localhost:3000/oauth2callback(or your chosen URI).
Required APIs
Gmail API
Google Docs API
OAuth scopes (least privilege)
https://www.googleapis.com/auth/gmail.compose— draft and sendhttps://www.googleapis.com/auth/documents— append to an existing Doc
The server does not request gmail.readonly, gmail.modify, or full Drive access.
Environment variables
Copy .env.example to .env (never commit .env):
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_REDIRECT_URI=http://localhost:3000/oauth2callback
GOOGLE_REFRESH_TOKEN=
LOG_LEVEL=infoOptional HTTP settings: MCP_HTTP_HOST, MCP_HTTP_PORT, MCP_HTTP_PATH, MCP_HTTP_TOKEN.
Obtain a refresh token once:
npm install
npm run authThe script opens a browser, requests consent, and prints GOOGLE_REFRESH_TOKEN. Paste it into .env or your host secret store.
Install and build
npm install
npm test
npm run buildHow to start the server
stdio (Cursor, Claude Desktop, local custom agents):
npx tsx src/index.ts
# or
npm run build && node dist/index.jsLogs go to stderr so they never mix with the MCP JSON-RPC stream on stdout.
Streamable HTTP (remote orchestrators, HTTP custom agents):
npx tsx src/index.ts --transport http --port 8787The MCP endpoint is http://127.0.0.1:8787/mcp by default. Bind stays on loopback unless you change --host. If MCP_HTTP_TOKEN is set, send Authorization: Bearer <token> or X-MCP-Token.
Railway (public Streamable HTTP — see docs/deployment-plan.md):
npm run build
npm run start:railwayRailway injects PORT. The process binds 0.0.0.0, serves GET /health, and requires MCP_HTTP_TOKEN (plus GOOGLE_* secrets). Do not upload token.json; set GOOGLE_REFRESH_TOKEN as a Railway variable.
How to connect an MCP client
Cursor
Add to .cursor/mcp.json or Cursor MCP settings:
{
"mcpServers": {
"google-workspace": {
"command": "node",
"args": ["dist/index.js"],
"env": {
"GOOGLE_CLIENT_ID": "<secret>",
"GOOGLE_CLIENT_SECRET": "<secret>",
"GOOGLE_REDIRECT_URI": "http://localhost:3000/oauth2callback",
"GOOGLE_REFRESH_TOKEN": "<secret>"
}
}
}
}Use an absolute path to dist/index.js if the workspace root is not the server directory.
Claude Desktop
Same JSON shape in claude_desktop_config.json (mcpServers.google-workspace).
Custom agents
Spawn the same command with StdioClientTransport, or connect a Streamable HTTP client to http://127.0.0.1:8787/mcp.
Remote orchestrators
Start --transport http and point the orchestrator at the MCP URL. Do not expose that port on a public network without TLS and an access token.
Example tool calls
Create a draft
{
"to": ["customer@example.com"],
"subject": "Customer Feedback Summary",
"body": "Draft email content..."
}Send email
{
"to": ["customer@example.com"],
"cc": [],
"bcc": [],
"subject": "Customer Feedback Summary",
"body": "Final email content..."
}Append to a Google Doc
{
"documentId": "google-document-id",
"content": "## Customer Feedback Summary\n\nCustomers highlighted..."
}The document id is the long id in the Doc URL: https://docs.google.com/document/d/<documentId>/edit.
Testing
npm testUnit tests mock Gmail and Docs clients. They do not need network access or real Google credentials.
Security considerations
Never hardcode credentials or commit
.env,credentials.json, ortoken.json.Access and refresh tokens are never returned in MCP responses.
The logger redacts token-like fields and does not log email bodies or document content at
info.Invalid input is rejected before any Google API call.
HTTP transport defaults to loopback. Treat it as an internal capability endpoint, not a public Google proxy.
Troubleshooting
Symptom | What to check |
Server exits on startup |
|
| Re-run |
No refresh token from | Revoke the app at https://myaccount.google.com/permissions and consent again. |
| The Doc id is wrong, or the authorized account cannot access that document. |
| One of |
Cursor/Claude cannot start the server | Use |
HTTP client 401 | Set the same |
Protocol errors on stdio | Do not write logs to stdout; this server logs to stderr only. |
Future extensions
Add generic tools only (no workflow-specific names):
read_google_doc
search_google_drive
create_google_doc
update_google_doc
list_gmail_messages
search_gmail
get_gmail_thread
create_google_sheet
append_to_google_sheetRegister a new tool, add a service method, request extra OAuth scopes only if required, and mock the Google client in tests.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
No tool schema history has been recorded yet.
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 Connectors
Read and edit GA4, Search Console and Google Tag Manager from any MCP client. 29 tools.
Provides tools for searching Google Workspace documentation and much more.
Email infrastructure for AI agents — send, receive, search, and reply to email over MCP.
Manage Gmail messages, threads, labels, drafts, and settings from your workflows. Send and organiz…
Related MCP Servers
- AlicenseBqualityCmaintenanceExposes Gmail (send/draft) and Google Docs (append) capabilities as tools for any MCP-compliant agent.347ISC
- FlicenseBqualityCmaintenanceEnables sending emails, drafting emails, and appending text to Google Docs via MCP tools.3-
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to send emails, create drafts in Gmail, and append content to Google Docs via standardized MCP tools.47ISC
- AlicenseNot gradedqualityCmaintenanceExposes standardized tools for AI agents to interact with Google Workspace (Gmail and Google Docs) via the MCP protocol.47ISC
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/himabindu-ai205/MCP-Server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server