Google Workspace MCP Server
An MCP-compliant server that exposes Gmail and Google Docs as tools, enabling AI agents to draft, send, and manage emails, as well as create, read, and append to documents through natural language.
README
Google Workspace MCP Server
A generic Model Context Protocol (MCP) Server that exposes Gmail and Google Docs as standardized tools, enabling any MCP-compatible AI agent (Claude, ChatGPT, Cursor, VS Code agents, etc.) to securely interact with Google Workspace.
Features
- Gmail Tools — Draft, update, send, and retrieve emails
- Google Docs Tools — Create, read, append to, and inspect documents
- OAuth 2.0 — Secure authentication with automatic token refresh
- MCP-Compliant — Works with any MCP client out of the box
- Structured Responses — Consistent JSON response envelopes for all tools
- Extensible — Modular architecture for adding Google Sheets, Drive, Calendar, etc.
Prerequisites
- Python 3.11+
- A Google Cloud project with Gmail API and Google Docs API enabled
- OAuth 2.0 credentials (
credentials.json)
Google Cloud Setup
- Go to the Google Cloud Console
- Create a new project (or select an existing one)
- Navigate to APIs & Services → Library
- Enable Gmail API and Google Docs API
- Navigate to APIs & Services → Credentials
- Click Create Credentials → OAuth 2.0 Client ID
- Select Desktop app as the application type
- Download the credentials file and save it as
credentials.jsonin the project root - Navigate to OAuth consent screen and add your email as a test user
Installation
# Clone the repository
git clone <repository-url>
cd google-mcp-server
# Create a virtual environment
python -m venv .venv
source .venv/bin/activate # macOS/Linux
# .venv\Scripts\activate # Windows
# Install the package
pip install -e .
# Install dev dependencies (optional)
pip install -e ".[dev]"
Configuration
Copy the environment template and configure:
cp .env.example .env
Edit .env as needed:
GOOGLE_CREDENTIALS_PATH=./credentials.json
GOOGLE_TOKEN_PATH=./token.json
LOG_LEVEL=INFO
First Run
On the first run, the server will open your browser for Google OAuth consent:
python -m google_mcp_server.server
- A browser window will open asking you to sign in to Google
- Grant the requested permissions (Gmail compose/read, Google Docs read/write)
- The token is saved to
token.jsonfor future use - The server starts on stdio transport, ready for MCP client connections
Available Tools
Gmail
| Tool | Description |
|---|---|
draft_email |
Create a new email draft with To, CC, BCC, Subject, and Body |
update_email_draft |
Update an existing draft (unchanged fields are preserved) |
send_new_email |
Send an email directly without creating a draft |
send_existing_draft |
Send a previously created draft |
get_email_draft |
Retrieve a draft by ID with headers and snippet |
Google Docs
| Tool | Description |
|---|---|
create_google_doc |
Create a new document with optional initial content |
read_google_doc |
Read the full text content of a document |
append_to_google_doc |
Append text to the end of a document |
get_google_doc_metadata |
Get document metadata (title, revision, URL) |
MCP Client Configuration
Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"google-workspace": {
"command": "python",
"args": ["-m", "google_mcp_server.server"],
"env": {
"GOOGLE_CREDENTIALS_PATH": "/absolute/path/to/credentials.json",
"GOOGLE_TOKEN_PATH": "/absolute/path/to/token.json"
}
}
}
}
Cursor
Add to your MCP settings:
{
"mcpServers": {
"google-workspace": {
"command": "python",
"args": ["-m", "google_mcp_server.server"],
"cwd": "/path/to/google-mcp-server"
}
}
}
VS Code (Copilot)
Add to your VS Code settings:
{
"mcp": {
"servers": {
"google-workspace": {
"command": "python",
"args": ["-m", "google_mcp_server.server"],
"cwd": "/path/to/google-mcp-server"
}
}
}
}
Vercel Deployment
This MCP server is configured for serverless deployment on Vercel using Server-Sent Events (SSE).
- Push your code to a GitHub repository.
- Go to the Vercel Dashboard and create a new project from your repository.
- In the environment variables section, add the following variable:
- Key:
GOOGLE_TOKEN_JSON - Value: (Paste the exact contents of your local
token.jsonfile)
- Key:
- Also add:
- Key:
VERCEL - Value:
1
- Key:
- Deploy the project!
Once deployed, your MCP SSE endpoint will be available at:
https://<your-vercel-domain>/sse
Clients connecting to a Vercel-deployed server must use the SSE transport configuration instead of the stdio transport.
Testing with MCP Inspector
Use the official MCP Inspector to test your server interactively:
npx -y @modelcontextprotocol/inspector python -m google_mcp_server.server
Running Tests
# Run all tests
pytest tests/ -v
# Run with coverage
pytest tests/ --cov=src/google_mcp_server --cov-report=term-missing
# Lint
ruff check src/ tests/
Docker
# Build
docker build -f docker/Dockerfile -t google-mcp-server .
# Run (mount your credentials)
docker run -it \
-v $(pwd)/credentials.json:/app/credentials.json \
-v $(pwd)/token.json:/app/token.json \
google-mcp-server
Project Structure
google-mcp-server/
├── pyproject.toml # Project config & dependencies
├── .env.example # Environment variable template
├── credentials.json # Google OAuth credentials (gitignored)
├── token.json # Cached OAuth token (gitignored)
├── src/
│ └── google_mcp_server/
│ ├── server.py # FastMCP server entry point
│ ├── config.py # Settings & environment loading
│ ├── auth/
│ │ └── oauth.py # OAuth 2.0 flow & token management
│ ├── gmail/
│ │ ├── service.py # Gmail API wrapper functions
│ │ └── tools.py # Gmail MCP tool definitions
│ ├── docs/
│ │ ├── service.py # Google Docs API wrapper functions
│ │ └── tools.py # Docs MCP tool definitions
│ └── utils/
│ └── errors.py # Error handling & response formatting
├── tests/ # Unit tests
└── docker/
└── Dockerfile # Docker deployment
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。