MCP Gmail Google Docs Integration
A generic MCP server that exposes Gmail and Google Docs capabilities as tools for AI agents. Enables sending emails and appending content to Google Docs.
README
Generic MCP Server for Gmail and Google Docs Integration
A generic Model Context Protocol (MCP) server that exposes Google Workspace capabilities as MCP tools. The server enables AI agents to interact with Gmail and Google Docs.
Features
- Gmail: Send emails (To, CC, BCC, Subject, Body). Supports Plain Text and HTML.
- Google Docs: Append plain text to an existing Google Document.
Prerequisites
- Node.js 18+ (if running locally)
- Docker (if running via container)
- Google Cloud Console Project
- Enable Gmail API
- Enable Google Docs API
- Configure OAuth Consent Screen (add yourself as a Test User)
- Create OAuth 2.0 Client IDs (Application Type: Web Application or Desktop)
- Add
http://localhost:3000/oauth2callbackas an Authorized redirect URI (if Web Application).
Local Setup & Generating the Refresh Token
To run this server (either locally or on a platform like Railway), you need an OAuth Refresh Token.
- Clone the repository and install dependencies:
npm install - Copy the example environment file:
cp .env.example .env - Open
.envand add yourGOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRET. - Run the token generation script:
npm run generate-tokens - Follow the prompt, log in with your Google account, and grant permissions.
- The script will automatically save your tokens into a
tokens.jsonfile in the root of the project. This file is loaded by the server when it runs.
Deployment
If you deploy this to a cloud environment (like Railway or Docker):
- You must ensure the
tokens.jsonfile you generated locally is available to the container. - If you are uploading code directly, DO NOT commit
tokens.jsonto a public repository. If it's a private repository, you can commit it. - If you want to change the file name, set the
TOKEN_STORAGE_PATHenvironment variable.
Deployment (Railway)
This repository is optimized for deployment on Railway.
- Push this repository to GitHub.
- In Railway, create a new project from your GitHub repository.
- In the Railway project settings, go to Variables and add:
GOOGLE_CLIENT_IDGOOGLE_CLIENT_SECRETTOKEN_STORAGE_PATH(if you want to override the default 'tokens.json')GOOGLE_REDIRECT_URI(optional, defaults tohttp://localhost:3000/oauth2callback)
- Railway will automatically detect the
package.json, install dependencies, run thebuildscript, and execute thestartscript using Nixpacks. - Alternatively, Railway can build from the provided
Dockerfileif you configure it to use Docker.
Connecting an MCP Client
Once deployed or running locally, you can connect an MCP Client (like Claude Desktop) to it.
If running locally:
{
"mcpServers": {
"gmail-gdoc": {
"command": "node",
"args": ["/path/to/your/project/dist/index.js"]
}
}
}
If deployed, you will likely connect via an SSE or HTTP transport (if you modify the transport layer) or through a remote execution bridge, depending on your agent's capabilities. Note: The current implementation uses standard input/output (stdio), which is ideal for local agent execution. For remote cloud execution, consider switching the transport to SSE in src/server.ts.
Available Tools
send_email
to: string[]cc?: string[]bcc?: string[]subject: stringbody: stringisHtml?: boolean
append_to_google_doc
documentId: stringcontent: string
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
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.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.