Google Workspace MCP Server

Google Workspace MCP Server

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

Category
Visit Server

README

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
  4. 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)
  5. 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"
    
  2. 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
    
  3. 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:

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:

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."}.

Recommended Servers

playwright-mcp

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.

Official
Featured
TypeScript
Magic Component Platform (MCP)

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.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

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.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

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.

Official
Featured
TypeScript
Kagi MCP Server

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.

Official
Featured
Python
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Exa Search

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.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured