Google MCP Server

Google MCP Server

Integrates with Google Docs and Gmail to append content to documents and create email drafts, featuring a manual approval system.

Category
Visit Server

README

Google MCP Server

A Python-based MCP-style server that integrates with Google Docs and Gmail, providing endpoints to append content to documents and create email drafts. Features a manual interactive terminal approval system for local environments, and environment-driven configurations for headless cloud environments like Railway.

Project Structure

google-mcp-server/
│
├── auth.py             # Google OAuth 2.0 authentication handler
├── docs_tool.py         # Google Docs API utility (append content)
├── gmail_tool.py        # Gmail API utility (create email draft)
├── server.py           # FastAPI app & approval prompt endpoint controller
│
├── requirements.txt    # Application dependencies
├── Dockerfile          # Container configuration for production
├── README.md           # Instructions & local setup documentation
└── deployment_plan.md  # Detailed Railway deployment instructions

1. Google Cloud Console Setup (Prerequisites)

Before running the server, you need to set up a project in the Google Cloud Console:

  1. Create/Select a Project: Go to the Google Cloud Console and create a new project.
  2. Enable Google APIs:
    • Navigate to API & Services > Library.
    • Search for Google Docs API and click Enable.
    • Search for Gmail API and click Enable.
  3. Configure the OAuth Consent Screen:
    • Go to API & Services > OAuth consent screen.
    • Choose External user type and click Create.
    • Fill in the required application registration details.
    • Scopes: Add the following scopes:
      • https://www.googleapis.com/auth/documents
      • https://www.googleapis.com/auth/gmail.compose
    • Test Users (CRITICAL): Under the "Test Users" section, click Add Users and enter the Gmail address you will use to log in and test. If you skip this, authentication will fail with a "Developer details not verified" error.
  4. Create Desktop Credentials:
    • Go to API & Services > Credentials.
    • Click Create Credentials and select OAuth client ID.
    • Select Desktop app as the Application Type.
    • Name your client (e.g., Google MCP Client) and click Create.
    • Download the client secrets JSON file.
    • Rename the downloaded file to credentials.json and place it in the root folder of this project (google-mcp-server/).

2. Local Setup and Token Generation

  1. Install Dependencies:

    pip install -r requirements.txt
    
  2. Generate token.json: Run the authentication handler script to start the local OAuth browser flow:

    python auth.py
    
    • This script will open your web browser automatically.
    • Select the Google Account added as a Test User.
    • Click "Continue" through warning pages (since it's a test application).
    • Grant permissions for Docs and Gmail.
    • Once completed, the browser will display "The authentication flow has completed..."
    • A token.json file will be auto-generated in your project directory. Keep this file secure as it contains authentication credentials.

3. Running the Server Locally

  1. Start the FastAPI server:

    python server.py
    

    The server will start on http://localhost:8000.

  2. Console Approval Mechanics: When any client requests a tool action via the POST endpoints, the server console will output the action name and request payload, and prompt for confirmation:

    ==============================================
    [APPROVAL REQUIRED] Action: append_to_doc
    Payload: {'doc_id': 'your-doc-id', 'content': 'Hello, world!'}
    ==============================================
    Approve? (y/n): 
    
    • Typing y or yes will authorize the request to interact with the Google API.
    • Typing n or no will refuse authorization, resulting in a 403 Forbidden response to the client.

4. Endpoints and Usage Examples

1. Append to Document

  • Endpoint: POST /append_to_doc
  • Content-Type: application/json
  • Request Body:
    {
      "doc_id": "YOUR_GOOGLE_DOCUMENT_ID",
      "content": "\nThis text is appended from the Google MCP Server!"
    }
    
  • cURL Command:
    curl -X POST http://localhost:8000/append_to_doc \
         -H "Content-Type: application/json" \
         -d '{"doc_id": "YOUR_GOOGLE_DOCUMENT_ID", "content": "\nThis text is appended from the Google MCP Server!"}'
    

2. Create Email Draft

  • Endpoint: POST /create_email_draft
  • Content-Type: application/json
  • Request Body:
    {
      "to": "recipient@example.com",
      "subject": "Hello from Google MCP",
      "body": "This is a draft email body created via the FastAPI Google MCP server."
    }
    
  • cURL Command:
    curl -X POST http://localhost:8000/create_email_draft \
         -H "Content-Type: application/json" \
         -d '{"to": "recipient@example.com", "subject": "Hello from Google MCP", "body": "This is a draft email body created via the FastAPI Google MCP server."}'
    

5. Deployment on Railway

For detailed, step-by-step instructions on deploying this project to Railway, managing environment-based secrets, and auto-bypassing approval prompts, see [deployment_plan.md](file:///c:/mcp%20server%20for%20ai%20agent/google-mcp-server/deployment_plan.md).

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
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

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
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