Google Workspace MCP Server
A complete MCP server integrating Gmail and Google Docs, enabling email management (list, send, search, reply) and document operations (create, edit, search, share) through natural language.
README
š§ Google Workspace MCP Server
A complete Model Context Protocol (MCP) server in Python that integrates Gmail and Google Docs into any MCP-compatible AI host (Claude Desktop, Cursor, etc.).
⨠Features
Gmail Tools (10)
| Tool | Description |
|---|---|
list_emails |
List emails from any mailbox label |
get_email |
Fetch full email body (HTML ā Markdown) |
search_emails |
Search with Gmail query syntax |
send_email |
Compose and send a new email |
reply_to_email |
Thread-aware reply |
create_draft |
Save a draft without sending |
trash_email |
Move to trash |
list_labels |
List all Gmail labels with counts |
add_label |
Apply a label to a message |
remove_label |
Remove a label from a message |
Google Docs Tools (8)
| Tool | Description |
|---|---|
list_documents |
List recent Google Docs |
get_document |
Fetch doc content as Markdown |
create_document |
Create a new doc (with optional content) |
update_document |
Append, prepend, or replace content |
search_documents |
Full-text search across all docs |
share_document |
Share with reader/writer/owner role |
export_document |
Export as PDF, DOCX, TXT, HTML, ODT |
delete_document |
Move to trash |
Resources (7)
| URI | Description |
|---|---|
gmail://inbox |
Latest 20 inbox emails |
gmail://message/{id} |
Single email as Markdown |
gmail://thread/{id} |
Full email thread |
gmail://labels |
All Gmail labels |
gdocs://list |
All accessible Google Docs |
gdocs://document/{id} |
Full doc as Markdown |
gdocs://document/{id}/metadata |
Doc title, owners, permissions |
Prompt Templates (6)
| Prompt | Description |
|---|---|
summarize_email_thread |
Summarise a thread (bullet, paragraph, exec summary) |
draft_reply |
Draft a context-aware reply |
review_document |
Review a doc (grammar, structure, clarity, tone) |
generate_document |
Generate a full doc from a topic |
email_to_doc |
Convert an email into a Google Doc |
daily_digest |
Create a digest of today's emails |
š Setup Guide
Step 1 ā Create a Google Cloud Project
- Go to Google Cloud Console
- Click Select a project ā New Project
- Give it a name (e.g.
MCP Workspace) and click Create
Step 2 ā Enable Required APIs
In the Cloud Console, go to APIs & Services ā Library and enable:
- ā Gmail API
- ā Google Docs API
- ā Google Drive API
Step 3 ā Create OAuth 2.0 Credentials
- Go to APIs & Services ā Credentials
- Click Create Credentials ā OAuth 2.0 Client ID
- If prompted, configure the OAuth consent screen:
- User Type: External (or Internal for Workspace orgs)
- Add your email as a test user
- Add these scopes:
https://www.googleapis.com/auth/gmail.modifyhttps://www.googleapis.com/auth/gmail.composehttps://www.googleapis.com/auth/gmail.sendhttps://www.googleapis.com/auth/documentshttps://www.googleapis.com/auth/drive
- Application type: Desktop app
- Click Create ā Download JSON
- Rename the downloaded file to
credentials.jsonand place it in theMCP-SERVERdirectory
Step 4 ā Install Dependencies
cd "C:\Users\Lavanya gupta\OneDrive\Documents\Ghratika\MCP-SERVER"
pip install -r requirements.txt
Or using a virtual environment (recommended):
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
Step 5 ā Configure Environment Variables
Copy the example .env file and fill it in:
copy .env.example .env
The defaults work out of the box if credentials.json is in the project root.
Step 6 ā Run the First-Time Auth Flow
python auth/google_auth.py
This will:
- Open your browser to the Google OAuth consent screen
- Ask you to log in and grant permissions
- Save a
token.jsonfile for future runs (no browser needed after this)
Step 7 ā Test with MCP Inspector
mcp dev server.py
This opens an interactive web UI where you can:
- Browse all 18 tools, 7 resources, and 6 prompts
- Call tools and see responses in real-time
- Test authentication before connecting to Claude Desktop
š„ļø Claude Desktop Integration
-
Open Claude Desktop's config file:
- Windows:
%APPDATA%\Claude\claude_desktop_config.json
- Windows:
-
Merge in the contents of
claude_desktop_config.jsonfrom this project:
{
"mcpServers": {
"google-workspace": {
"command": "python",
"args": [
"C:/Users/Lavanya gupta/OneDrive/Documents/Ghratika/MCP-SERVER/server.py"
],
"env": {
"GOOGLE_CREDENTIALS_PATH": "C:/Users/Lavanya gupta/OneDrive/Documents/Ghratika/MCP-SERVER/credentials.json",
"GOOGLE_TOKEN_PATH": "C:/Users/Lavanya gupta/OneDrive/Documents/Ghratika/MCP-SERVER/token.json",
"LOG_LEVEL": "INFO"
}
}
}
}
- Restart Claude Desktop ā the Google Workspace tools will appear in the tools list.
Tip: If using a virtual environment, replace
"python"with the full path to your venv Python:"C:/Users/Lavanya gupta/OneDrive/Documents/Ghratika/MCP-SERVER/.venv/Scripts/python.exe"
š SSE (Remote HTTP) Mode
To run the server as an HTTP endpoint (e.g. for Cursor or remote clients):
python server.py --sse --port 8000
The server will be available at http://localhost:8000/sse.
š Project Structure
MCP-SERVER/
āāā server.py ā Main entrypoint
āāā credentials.json ā Your OAuth2 client credentials (DO NOT COMMIT)
āāā token.json ā Auto-generated after first login (DO NOT COMMIT)
āāā .env ā Your environment variables (DO NOT COMMIT)
āāā .env.example ā Environment variable template
āāā requirements.txt ā Python dependencies
āāā claude_desktop_config.json ā Ready-to-paste Claude Desktop config
āāā auth/
ā āāā google_auth.py ā OAuth2 lifecycle manager
āāā tools/
ā āāā gmail_tools.py ā Gmail MCP tools
ā āāā docs_tools.py ā Google Docs MCP tools
āāā resources/
ā āāā gmail_resources.py ā Gmail MCP resources
ā āāā docs_resources.py ā Google Docs MCP resources
āāā prompts/
ā āāā google_prompts.py ā MCP prompt templates
āāā utils/
āāā html_to_text.py ā HTML ā Markdown converter
āāā docs_parser.py ā Google Docs JSON ā Markdown parser
š Security Notes
ā ļø Never commit these files to version control:
credentials.jsonā your OAuth2 client secrettoken.jsonā your personal access token.envā your environment configuration
Add them to .gitignore:
credentials.json
token.json
.env
š§ Troubleshooting
"credentials.json not found"
Download it from Google Cloud Console ā APIs & Services ā Credentials.
"Access blocked: This app's request is invalid"
Make sure the OAuth consent screen is configured and your email is added as a test user.
"Token has been expired or revoked"
Delete token.json and run python auth/google_auth.py again.
"ModuleNotFoundError: No module named 'mcp'"
Install dependencies: pip install -r requirements.txt
Tools not appearing in Claude Desktop
- Verify the path in
claude_desktop_config.jsonuses forward slashes - Check Claude Desktop logs at
%APPDATA%\Claude\logs\ - Make sure Python is in your PATH
š Example Workflows
Summarise unread emails
"Check my unread emails and give me a daily digest" ā Uses
search_emails+daily_digestprompt
Draft and send a reply
"Reply to the latest email from john@example.com ā say I'll be there" ā Uses
search_emails+get_email+send_email
Create a document from an email
"Turn this email thread into a Google Doc summary" ā Uses
get_email+create_document
Find and review a document
"Find my Q4 report document and review its structure" ā Uses
search_documents+get_document+review_documentprompt
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
Neon Database
MCP server for interacting with Neon Management API and databases
E2B
Using MCP to run code via e2b.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.