Featured

Deploy OpenClaw in 60 seconds — 20% off logoDeploy OpenClaw in 60 seconds — 20% off

Launch OpenClaw on Hostinger in about 60 seconds and keep your agent live 24/7. Our referral link gives you 20% off, no coupon code needed.

Launch on Hostinger
Run your Hermes agent on Hostinger, fully managed logoRun your Hermes agent on Hostinger, fully managed

Launch Hermes on Hostinger in one click, fully managed, no VPS knowledge needed. Use code ZACAARON10 for 10% off.

Launch on Hostinger
Crawl and scrape any site into clean data, 10% off logoCrawl and scrape any site into clean data, 10% off

Firecrawl crawls and scrapes any site into clean markdown for your agent. Get 1,000 free credits, and new users get 10% off their first purchase.

Try Firecrawl free
Your own AI agent, running 24/7 with QwikClaw logoYour own AI agent, running 24/7 with QwikClaw

QwikClaw sets up and runs an always-on OpenClaw agent for you. One click, no config files, no server setup.

Deploy now
One API to scrape, enrich, and extract the internet. logoOne API to scrape, enrich, and extract the internet.

Context.dev gives your agents a single API to scrape, enrich, and extract live web data — no proxies, no parsers, no maintenance.

Start building free
SetupClaw: done-for-you OpenClaw for founders & exec teams logoSetupClaw: done-for-you OpenClaw for founders & exec teams

White-glove OpenClaw for founders and exec teams (4–50+ employees): we install, harden, integrate your tools, and maintain it — secured from day one.

Get it set up for you
SEO data APIs for your agent, $1 free credit logoSEO data APIs for your agent, $1 free credit

DataForSEO gives your agent live access to SERP results, keyword data, backlinks, and on-page SEO data through one API. New accounts get a $1 credit, good for up to 20,000 keyword or backlink lookups.

Try DataForSEO free
Reach 47,000+ AI builders

A flat monthly placement in front of developers actively installing AI tools. No lock-in, cancel anytime.

Advertise here

Works with

Claude CodeClaude DesktopCursorVS CodeClineCodex CLIOpenClaw+ any MCP client

Install to Claude Code

This server doesn't publish a one-line install command. Follow the setup in the source repository.

Summary

A Python-based MCP server that integrates Google Docs and Gmail, allowing appending text to documents and creating email drafts with terminal approval prompts.

README.md

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 login

---

⚙️ Prerequisites

To run this server, you need to acquire a Google client configuration file:

  1. Go to the Google Cloud Console.
  2. Create a new project (or select an existing one).
  3. Enable the following APIs:
  • Google Docs API
  • Gmail API
  1. 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)
  1. 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.json and place it in the root of this project directory.

---

🚀 Setup & Installation

  1. Clone/Navigate to the workspace directory:
   cd "c:\Users\amoln\Airtribe Projects\gmail_gdrive_mcp_server"
  1. 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/activate
  1. Install 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: ``bash python auth.py ` This 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: ``bash python server.py ``

The server will start listening on http://127.0.0.1:8005.

---

🧪 API Endpoints & Usage

1. Append to Google Doc

  • Endpoint: POST /append_to_doc
  • Request 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_draft
  • Request 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 y and press Enter: The action is sent to the Google APIs. The client receives a 200 OK response.
  • Type n and press Enter: The action is rejected. The API blocks execution and returns a 403 Forbidden response: {"detail":"Action rejected by user."}.

See related servers & alternatives →

Related MCP servers

Browse all →

Related guides

Hand-picked reading to help you choose and use Communication servers.