Google MCP Server
Provides tools to create Gmail email drafts.
Provides tools to append content to Google Docs.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Google MCP ServerAppend today's notes to my project doc"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Google MCP Server
A Python-based MCP-style server built with FastAPI that integrates with Google Docs and Gmail. Before running any action, the server requires manual approval in the terminal (Approve? (y/n)).
๐ Project Structure
google-mcp-server/
โโโ server.py # FastAPI app with tool endpoints & approval prompt
โโโ auth.py # Google OAuth authentication & token manager
โโโ docs_tool.py # Google Docs tool (appends content)
โโโ gmail_tool.py # Gmail tool (creates draft)
โโโ requirements.txt # Python dependencies
โโโ README.md # Setup and usage instructions
โโโ credentials.json # (NOT committed) OAuth 2.0 client secret credentials from Google Cloud Console
โโโ token.json # (NOT committed) Auto-generated user access/refresh tokenRelated MCP server: Google MCP Server
โ๏ธ Features
FastAPI Endpoints:
POST /append_to_doc: Appends text to the end of a Google Doc body.POST /create_email_draft: Creates a draft email in your Gmail drafts folder.
Operator-in-the-loop Verification:
Whenever an endpoint is hit, the server pauses, prints the payload, and prompts
Approve? (y/n)in the command line interface.The API client waits and will receive a
200 OKon approval (y), or a403 Forbiddenon rejection (n).
Seamless Google OAuth2 Flow:
Skips web authentication on subsequent runs if a valid
token.jsonalready exists.
๐ Setup Instructions
1. Prerequisites & Virtual Environment
Ensure you have Python 3.10+ installed.
# Clone or navigate to the project directory
cd google-mcp-server
# Create a virtual environment
python -m venv venv
# Activate the virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate
# Install the dependencies
pip install -r requirements.txt2. Configure Google Cloud Console
To interact with the APIs, you must download a client secrets credentials file:
Open the Google Cloud Console.
Create a new Google Cloud Project (or select an existing one).
Enable the Google Docs API and Gmail API:
Go to APIs & Services > Library.
Search for Google Docs API and click Enable.
Search for Gmail API and click Enable.
Configure the OAuth Consent Screen:
Go to APIs & Services > OAuth consent screen.
Select External (or Internal if you are within a Google Workspace organization) and click Create.
Fill in the required fields (App Name, User support email, Developer contact information).
Under Scopes, you can add or skip (the app requests scopes dynamically).
Under Test Users, add the Google email address you plan to authenticate with.
Create OAuth 2.0 Client Credentials:
Go to APIs & Services > Credentials.
Click Create Credentials and select OAuth client ID.
Select Desktop App as the Application Type.
Set a name (e.g.,
Google MCP Server Desktop Client) and click Create.
Download the Client Secret:
In the Credentials list, find your new Client ID under OAuth 2.0 Client IDs.
Click the Download JSON icon on the right.
Rename the downloaded file to
credentials.jsonand save it directly in thegoogle-mcp-server/directory.
๐ Initial Authentication
Before running the server, you can optionally test and run the OAuth authentication flow standalone to create token.json:
python auth.pyThis will automatically open your default web browser. Log in with your test Google account, accept the security warnings (as this is your own developer app), and authorize the requested permissions for Docs and Gmail.
Once completed, a file named token.json will be saved in the directory, allowing future executions to run headlessly.
๐ข Running the Server
Start the server using uvicorn or by running the script directly:
python server.pyThe server will launch at http://127.0.0.1:8000.
๐งช Testing the Endpoints
Keep the server running and open a new terminal window to execute test requests using curl.
Test 1: Append text to a Google Doc
Replace YOUR_DOCUMENT_ID with the ID of a Google Document you own and have edit access to (from the document URL: https://docs.google.com/document/d/YOUR_DOCUMENT_ID/edit).
curl -X POST "http://127.0.0.1:8000/append_to_doc" \
-H "Content-Type: application/json" \
-d "{\"doc_id\": \"YOUR_DOCUMENT_ID\", \"content\": \"\nHello from the Google MCP-style Server!\"}"Terminal prompt response:
In the server terminal, you will see:
================================================== PENDING OPERATOR APPROVAL Action: append_to_doc Payload: doc_id: YOUR_DOCUMENT_ID content: \nHello from the Google MCP-style Server! ================================================== Approve? (y/n):Type
yand press Enter.The API client will receive:
{ "status": "success", "message": "Text successfully appended to Google Doc", "documentId": "YOUR_DOCUMENT_ID", "response": { ... } }Verify the new line in your Google Doc!
Test 2: Create a Gmail Email Draft
curl -X POST "http://127.0.0.1:8000/create_email_draft" \
-H "Content-Type: application/json" \
-d "{\"to\": \"recipient@example.com\", \"subject\": \"FastAPI MCP Server Test\", \"body\": \"This email draft was generated using the Python Google API server integration with console-based approval validation.\"}"Terminal prompt response:
In the server terminal, approve the request by typing
yand pressing Enter.Go to Gmail Drafts in your browser and verify the new draft is created.
Try sending another request and typing
nto reject it. Verify that the server returns a403 Forbiddenresponse:{ "detail": "Action rejected by user." }
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Shubham070520/mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server