Google Docs + Gmail MCP Server
README.md
# ๐ Google Docs + Gmail MCP Server
A lightweight MCP-style server that integrates with Google Docs and Gmail.
This project demonstrates how to build **structured AI tool interfaces with approval gating**, inspired by the Model Context Protocol (MCP).
---
## โจ Features
- ๐ Append structured content to Google Docs
- ๐ง Create Gmail drafts
- ๐ OAuth-based Google authentication
- ๐ง MCP-style tool interface
- โ
Human-in-the-loop approval before execution
- ๐งฉ Modular and extensible design
---
## How to Use in Your Project
1. Run the MCP server:
uvicorn server:app --reload
2. Call tools via API:
POST /append_to_doc
POST /create_email_draft
3. Integrate with your AI workflow:
- Generate content using LLM
- Send output to these endpoints
---
## ๐ Project Structure
```
google-mcp-server/
โโโ server.py
โโโ auth.py
โโโ docs_tool.py
โโโ gmail_tool.py
โโโ requirements.txt
โโโ credentials.json (not committed)
โโโ token.json (not committed)
โโโ README.md
```
---
## โ๏ธ Setup
### 1. Clone the repository
```
git clone <your-repo-url>
cd google-mcp-server
```
### 2. Create virtual environment
```
python3 -m venv venv
source venv/bin/activate
```
### 3. Install dependencies
```
pip install -r requirements.txt
```
### 4. ๐ Google API Setup
1. Go to Google Cloud Console
2. Create a new project
3. Enable:
* Google Docs API
* Gmail API
4. Configure OAuth Consent Screen
5. Create OAuth Credentials (Desktop App)
6. Download `credentials.json`
7. Place it in project root
---
### 5. ๐ Run OAuth
```
python3 auth.py
```
- Opens browser for login
- Generates token.json
### 6. โถ๏ธ Run Server
```
uvicorn server:app --reload
```
Open:
```
http://127.0.0.1:8000/docs
```
## ๐งช How to Test
### Append to Google Doc
Endpoint: `POST /append_to_doc`
Example:
```json
{
"doc_id": "YOUR_DOC_ID",
"content": "Hello from MCP ๐"
}
```
---
### Create Email Draft
Endpoint: `POST /create_email_draft`
Example:
```json
{
"to": "test@example.com",
"subject": "Test Draft",
"body": "This is a test email"
}
```
### ๐ Workflow
```
Request โ Approval โ Tool Execution โ Response
```
- Every action requires manual approval
- Ensures safe and controlled execution
### โ ๏ธ Important Notes
Do NOT commit:
- credentials.json
- token.json
Approval is CLI-based (terminal input)
Designed for local development
---
## โ ๏ธ Approval Flow
Every action requires manual approval in terminal:
```
ACTION: append_to_doc
PAYLOAD: {...}
Approve? (y/n):
```
Type:
```
y
```
---
## ๐ง MCP Design
This project demonstrates:
* Structured tool calls
* Separation of generation and execution
* Human approval before tool execution
---
## โ Notes
* No emails are sent automatically (draft only)
* Google Doc must have edit access
* Token is stored locally
---
## ๐ License
Apache License
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo issues