Skip to main content
Glama
girishbr4

Google Workspace MCP Server

by girishbr4

Google Workspace MCP Server

An agent-agnostic Model Context Protocol (MCP) server that exposes Gmail and Google Docs as tools for any MCP-compliant AI agent (Claude, Gemini, GPT, or custom agents).

Tools Exposed

Tool

Description

send_email

Compose and immediately send an email

draft_email

Save an email as a Gmail draft for human review

append_to_doc

Append text to an existing Google Document

Related MCP server: Generic Google Workspace MCP Server

Quick Start

1. Install dependencies

pip install -r requirements.txt

2. Configure credentials

Copy .env.example to .env and fill in your Google OAuth 2.0 credentials:

cp .env.example .env
GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=your-client-secret
GOOGLE_REFRESH_TOKEN=your-long-lived-refresh-token

How to get credentials: Go to Google Cloud Console → APIs & Services → Credentials → Create OAuth 2.0 Client ID. Enable the Gmail API and Google Docs API. Then run the interactive login flow once to generate a refresh token (see §Auth below).

3. Run the server

stdio mode (default — for local agent integrations):

python -m src.server

SSE mode (for remote/HTTP agents):

MCP_TRANSPORT=sse python -m src.server
# Server starts on http://localhost:3000

Authentication

The server loads Google OAuth 2.0 credentials in this priority order:

  1. Environment variablesGOOGLE_CLIENT_ID + GOOGLE_CLIENT_SECRET + GOOGLE_REFRESH_TOKEN (recommended for production)

  2. token.json — Cached token from a prior interactive login (auto-generated)

  3. credentials.json — Standard Google OAuth client secrets file → triggers interactive browser consent flow on first run

Getting a Refresh Token

If you don't have a refresh token yet, place your credentials.json in the project root and run:

python -m src.server

The server will open a browser for the Google consent screen, then cache the token in token.json for future runs.


Project Structure

mcp-google-workspace/
├── src/
│   ├── server.py              # Entry point
│   ├── config/config.py       # Configuration manager
│   ├── auth/auth_manager.py   # OAuth 2.0 credential management
│   ├── tools/
│   │   ├── registry.py        # Tool registry
│   │   ├── gmail/
│   │   │   ├── send_email.py
│   │   │   └── draft_email.py
│   │   └── docs/
│   │       └── append_to_doc.py
│   ├── adapters/
│   │   ├── gmail_adapter.py
│   │   └── docs_adapter.py
│   └── errors/error_handler.py
├── .env.example
├── .gitignore
├── requirements.txt
└── pyproject.toml

Connecting to Claude Desktop

Add this to your Claude Desktop claude_desktop_config.json:

{
  "mcpServers": {
    "google-workspace": {
      "command": "python",
      "args": ["-m", "src.server"],
      "cwd": "/path/to/MCPserver"
    }
  }
}

OAuth 2.0 Scopes Required

  • https://www.googleapis.com/auth/gmail.send

  • https://www.googleapis.com/auth/gmail.compose

  • https://www.googleapis.com/auth/documents

Security

  • Credentials are never logged or hardcoded

  • .env, credentials.json, and token.json are gitignored

  • Minimum required OAuth scopes only

Related MCP Connectors

  • Email infrastructure for AI agents — send, receive, search, and reply to email over MCP.

  • MCP server connecting AI agents to 100+ apps (Gmail, Slack, Notion, GitHub) via one-click OAuth.

  • Your agent needs a mailbox of its own — to receive, thread, draft and send, with attachments, without borrowing your personal inbox or your company's SMTP. **What you can ask for** • "Create an inbox for this agent and tell me its address." • "Read the new messages in this thread and draft a reply." • "Send this message with the attachment and wait for the response." • "Search this inbox for everything from that domain." • "Show delivery metrics and the events on this inbox." **How to use it** Point any MCP client at https://mcp.aisa.one/mail/mcp and sign in with OAuth — there is no key to create or paste. 49 tools: create and delete inboxes, list and read messages, raw message bodies, attachments, threads, drafts and draft attachments, send and reply, message search, inbox events, metrics, and list entries — reads and writes. **Why this rather than the source** A real inbox an agent owns, rather than an SMTP credential it borrows from a human. **It is also a door to the rest** The same login reaches 26 sources and 580+ operations. Find the contact elsewhere in the catalogue, then write to them from here — without adding a second server. **What it costs** Finding and inspecting an operation is free. Running one is billed per call at API prices, with no seat and no monthly minimum, and every call takes max_price_usd so an agent cannot overspend by accident. **Where else it reaches** https://mcp.aisa.one/sales/mcp finds the person to write to.

  • Automate 1,000+ services from any MCP-compatible AI agent: build Applets, run actions and queries.

Related MCP Servers