Google MCP Server
Integrates with Google Docs and Gmail to append content to documents and create email drafts, featuring a manual approval system.
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:
- Create/Select a Project: Go to the Google Cloud Console and create a new project.
- Enable Google APIs:
- Navigate to API & Services > Library.
- Search for Google Docs API and click Enable.
- Search for Gmail API and click Enable.
- 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/documentshttps://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.
- 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.jsonand place it in the root folder of this project (google-mcp-server/).
2. Local Setup and Token Generation
-
Install Dependencies:
pip install -r requirements.txt -
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.jsonfile will be auto-generated in your project directory. Keep this file secure as it contains authentication credentials.
3. Running the Server Locally
-
Start the FastAPI server:
python server.pyThe server will start on
http://localhost:8000. -
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
yoryeswill authorize the request to interact with the Google API. - Typing
nornowill refuse authorization, resulting in a403 Forbiddenresponse to the client.
- Typing
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
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
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.
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.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
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.
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.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
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.