google-workspace-mcp-server
Allows sending or drafting emails via Gmail.
Allows appending plain text or markdown content to Google Docs.
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., "@google-workspace-mcp-serversend email to team@co.com about standup"
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
A generic, agent-agnostic MCP (Model Context Protocol) server that exposes Gmail and Google Docs as tools any AI agent can call.
Tool | Description |
| Send or draft emails via Gmail |
| Append plain text or markdown to a Google Doc |
Built with FastMCP — any MCP-compatible client (Claude Desktop, Cursor, custom agents) can discover and invoke these tools automatically..
Prerequisites
Python 3.10+
Google Cloud project with Gmail API and Google Docs API enabled
OAuth 2.0 Client ID (Desktop application type)
Related MCP server: Google Workspace MCP Server
Google Cloud Setup
If you don't have a Google Cloud project yet, follow these steps:
Go to Google Cloud Console
Create a new project (or select an existing one)
Enable APIs:
Navigate to APIs & Services → Library
Search for and enable Gmail API
Search for and enable Google Docs API
Create OAuth Credentials:
Go to APIs & Services → Credentials
Click Create Credentials → OAuth 2.0 Client ID
Application type: Desktop app
Download the JSON file and save it as
credentials.jsonin the project root
Configure OAuth Consent Screen:
Go to APIs & Services → OAuth consent screen
Choose External (or Internal for Workspace)
Add your email as a test user
Add scopes:
https://www.googleapis.com/auth/gmail.sendhttps://www.googleapis.com/auth/gmail.composehttps://www.googleapis.com/auth/documents
Installation
# Clone the repository
git clone <your-repo-url>
cd "MCP Server"
# Create and activate a virtual environment
python -m venv venv
venv\Scripts\activate # Windows
# source venv/bin/activate # macOS/Linux
# Install dependencies
pip install -r requirements.txtConfiguration
Copy the example environment file and adjust if needed:
cp .env.example .envVariable | Default | Description |
|
| Path to OAuth client ID JSON |
|
| Path where the auth token is saved |
First Run & Authentication
python server.pyOn the first run, your browser will open for Google OAuth consent. Grant the requested permissions. A token.json file will be created automatically — subsequent runs will use this token (and refresh it when expired).
Note: When using stdio transport, the server communicates via stdin/stdout. The OAuth browser flow happens once; after that, the server runs headless.
Connecting to AI Agents
Claude Desktop
Add the following to your claude_desktop_config.json:
{
"mcpServers": {
"google-workspace": {
"command": "python",
"args": ["C:/full/path/to/MCP Server/server.py"]
}
}
}Restart Claude Desktop — the tools will appear in the tool picker.
Cursor
Add to your Cursor MCP config (.cursor/mcp.json):
{
"mcpServers": {
"google-workspace": {
"command": "python",
"args": ["C:/full/path/to/MCP Server/server.py"]
}
}
}MCP Inspector (Testing)
mcp dev server.pyThis opens a web UI where you can test both tools interactively.
Tool Reference
gmail_send_email
Send an email or save it as a draft.
Parameters:
Name | Type | Required | Description |
|
| ✅ | Recipient email addresses |
|
| ✅ | Email subject line |
|
| ✅ | Email body (plain text or HTML) |
|
| ❌ | CC recipients |
|
| ❌ | BCC recipients |
|
| ❌ | Save as draft instead of sending (default: |
Example response:
{
"status": "sent",
"message_id": "18a1b2c3d4e5f6g7",
"thread_id": "18a1b2c3d4e5f6g7"
}google_docs_append
Append content to an existing Google Doc.
Parameters:
Name | Type | Required | Description |
|
| ✅ | Google Doc ID (from URL) |
|
| ✅ | Text to append |
|
| ❌ |
|
Example response:
{
"status": "appended",
"document_id": "1BxiMVs0XRA5nFMdKvBdBZjgmUii3Op3Rp6mLbKd",
"characters_added": 142
}Markdown support: When format="markdown", the tool converts:
# Heading→ Google Docs Heading 1–6**bold**→ Bold text*italic*→ Italic text
Development
Running Unit Tests
# All unit tests (no credentials needed)
pytest tests/test_gmail_tool.py tests/test_docs_tool.py -vRunning Integration Tests
Requires real credentials and environment variables:
# Set test targets
set TEST_DOCUMENT_ID=your-google-doc-id
set TEST_EMAIL_RECIPIENT=your-email@example.com
# Run integration tests
pytest tests/test_integration.py -v -m integrationAdding a New Tool
Create a new module in
tools/(e.g.,tools/sheets_tool.py)Add any new scopes to
config/scopes.pyRegister the tool in
server.pywith@mcp.tool()Add unit tests in
tests/Re-run
python server.pyor restart your MCP client
Deploy to Railway
This server can be deployed to Railway for remote access via SSE transport.
Step 1: Push to GitHub
git init
git add .
git commit -m "Initial commit: MCP server for Gmail & Google Docs"
git remote add origin https://github.com/<YOUR_USERNAME>/<REPO_NAME>.git
git branch -M main
git push -u origin mainStep 2: Create Railway Project
Go to railway.app → sign in
New Project → Deploy from GitHub Repo → select your repo
Railway will auto-detect the
Procfileand start deploying
Step 3: Set Environment Variables
In Railway dashboard → your service → Variables tab:
Variable | Value |
| Paste the entire contents of your local |
|
|
Note: Railway automatically sets
PORT. The server detects this and switches to SSE transport.
Step 4: Connect Your Agent
After deploy, Railway provides a public URL. Your SSE endpoint is:
https://your-app.railway.app/sseClaude Desktop (remote SSE):
{
"mcpServers": {
"google-workspace": {
"url": "https://your-app.railway.app/sse"
}
}
}Project Structure
MCP Server/
├── server.py # MCP server entry point (FastMCP)
├── Procfile # Railway process definition
├── runtime.txt # Python version for Railway
├── tools/
│ ├── gmail_tool.py # Gmail send/draft logic
│ └── google_docs_tool.py # Google Docs append logic
├── auth/
│ └── google_auth.py # Shared OAuth 2.0 auth helper
├── config/
│ └── scopes.py # Centralised Google API scopes
├── tests/
│ ├── test_gmail_tool.py # Gmail unit tests
│ ├── test_docs_tool.py # Docs unit tests
│ └── test_integration.py # End-to-end integration tests
├── generate_token.py # OAuth token generator utility
├── credentials.json # OAuth client ID (gitignored)
├── token.json # Auto-generated token (gitignored)
├── requirements.txt
├── .env.example
├── .gitignore
└── README.mdSecurity
credentials.json and token.json are gitignored — never commit them.
For deployment, credentials are loaded from environment variables — no secrets in code.
The server uses least-privilege scopes (send/compose for Gmail, documents for Docs).
AI agents never see or handle Google credentials — the MCP server manages auth internally.
No PII is logged.
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.
Latest Blog Posts
- 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/priyankaverma-1998/mcp-server-groww-weekly-pulse-reviewer'
If you have feedback or need assistance with the MCP directory API, please join our Discord server