Google Workspace MCP Server
Allows creating email drafts in Gmail.
Allows appending content to Google Documents.
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 Serverdraft an email to alice@example.com about tomorrow's agenda"
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
This is a Python-based Model Context Protocol (MCP) style server integrating Google Docs and Gmail. It is built with FastAPI and runs on a local web server, exposing endpoints to append text to Google Documents and create email drafts in Gmail.
Before any action is executed, the server prompts the user in the terminal for approval: Approve? (y/n).
๐ Project Structure
google-mcp-server/
โโโ server.py # FastAPI server with tool endpoints & terminal approval logic
โโโ auth.py # Google OAuth 2.0 authentication flow
โโโ docs_tool.py # Google Docs tool (append content to document)
โโโ gmail_tool.py # Gmail tool (create email draft)
โโโ requirements.txt # Python package dependencies
โโโ README.md # Setup and usage instructions
โโโ credentials.json # (NOT committed) OAuth client credentials downloaded from Google Cloud
โโโ token.json # (NOT committed) Auto-generated user token after successful loginRelated MCP server: Google Docs + Gmail MCP Server
โ๏ธ Prerequisites
To run this server, you need to acquire a Google client configuration file:
Go to the Google Cloud Console.
Create a new project (or select an existing one).
Enable the following APIs:
Google Docs API
Gmail API
Set up the OAuth consent screen:
Choose External user type (or Internal if using a Google Workspace organization account).
Add test users (include your own Gmail address).
Add the scopes:
https://www.googleapis.com/auth/documents(to append to documents)https://www.googleapis.com/auth/gmail.compose(to create drafts)
Create Credentials:
Click Create Credentials -> OAuth client ID.
Select application type: Desktop app.
Name it, click Create, and click Download JSON.
Rename the downloaded file to
credentials.jsonand place it in the root of this project directory.
๐ Setup & Installation
Clone/Navigate to the workspace directory:
cd "c:\Users\amoln\Airtribe Projects\gmail_gdrive_mcp_server"Create and activate a virtual environment (optional but recommended):
python -m venv venv # On Windows (PowerShell): .\venv\Scripts\Activate.ps1 # On macOS/Linux: source venv/bin/activateInstall the dependencies:
pip install -r requirements.txt
๐ Authentication
The authentication module auth.py automatically checks for a token.json file. If it doesn't exist, it opens a local browser server to execute the Google login flow.
You can trigger authentication manually before running the server:
python auth.pyThis will open your browser. Grant the necessary permissions for Google Docs and Gmail, and the script will save token.json in the root folder. Future runs will read token.json directly and skip the browser login.
๐ Running the Server
Start the FastAPI server:
python server.pyThe server will start listening on http://127.0.0.1:8005.
๐งช API Endpoints & Usage
1. Append to Google Doc
Endpoint:
POST /append_to_docRequest Body (JSON):
{ "doc_id": "YOUR_GOOGLE_DOCUMENT_ID", "content": "This text will be appended to the document.\n" }Example request (
curl):curl -X POST "http://127.0.0.1:8005/append_to_doc" \ -H "Content-Type: application/json" \ -d "{\"doc_id\": \"1234567890abcdefghijklmnopqrstuvwxyz\", \"content\": \"Hello Google Docs!\n\"}"
2. Create Gmail Draft
Endpoint:
POST /create_email_draftRequest Body (JSON):
{ "to": "recipient@example.com", "subject": "Hello from MCP Server", "body": "This is the body of the draft email." }Example request (
curl):curl -X POST "http://127.0.0.1:8005/create_email_draft" \ -H "Content-Type: application/json" \ -d "{\"to\": \"recipient@example.com\", \"subject\": \"Test Subject\", \"body\": \"This is a test draft body.\"}"
๐ก๏ธ Terminal Approval Prompt
Whenever a request is sent to either of the endpoints, the server output will print the request details in the terminal and block:
========================================
ACTION NAME: append_to_doc
PAYLOAD:
doc_id: 1234567890abcdefghijklmnopqrstuvwxyz
content: Hello Google Docs!
========================================
Approve? (y/n): Type
yand press Enter: The action is sent to the Google APIs. The client receives a200 OKresponse.Type
nand press Enter: The action is rejected. The API blocks execution and returns a403 Forbiddenresponse:{"detail":"Action rejected by user."}.
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
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/naikamol76/gmail_gdoc_mcp_server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server