Skip to main content
Glama
SPSahoo007

Google Services MCP Server

by SPSahoo007

Google Services MCP Server

A Model Context Protocol (MCP) server that exposes Google services — specifically Gmail and Google Docs — as standardized tools for AI agents.

This allows MCP-compatible agents (like Claude Desktop, Cursor, or custom agents) to seamlessly send/draft emails and append content to Google Docs on your behalf.


Capabilities (Tools)

Tool

Description

gmail_send_email

Send an email to one or more recipients with subject, body (text/html), and optional CC/BCC.

gmail_draft_email

Create a draft email in your Gmail account without sending it.

gdocs_append_content

Append text content to the end of an existing Google Doc, with optional formatting (heading level, bold, italic).


Related MCP server: Gmail & Google Docs MCP Server

Prerequisites

  1. Node.js: Version 20 or higher.

  2. Google Cloud Project: You need to set up a project and obtain OAuth 2.0 credentials.


šŸ› ļø Google Cloud Setup Guide

  1. Go to the Google Cloud Console.

  2. Create a new project (e.g., "MCP Server").

  3. Go to APIs & Services > Library.

    • Search for and enable the Gmail API.

    • Search for and enable the Google Docs API.

  4. Go to APIs & Services > OAuth consent screen.

    • Choose External (or Internal if you have a Workspace).

    • Fill out the App Name, User support email, and Developer contact information.

    • Click Save and Continue.

    • Under Scopes, add:

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

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

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

    • Finish the consent screen setup.

  5. Go to APIs & Services > Credentials.

    • Click Create Credentials > OAuth client ID.

    • Application type: Web application.

    • Name: "MCP Server Local".

    • Under Authorized redirect URIs, add exactly: http://localhost:3000/oauth2callback

    • Click Create.

    • Note down your Client ID and Client Secret.


šŸš€ Installation & Authentication

  1. Clone or copy this repository.

  2. Install dependencies:

    npm install
  3. Copy the environment template:

    cp .env.example .env
  4. Open .env and fill in your GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET.

  5. Run the authentication script to obtain your refresh token:

    npm run authenticate
  6. Follow the prompt in your browser to authorize the app. Once completed, the terminal will output a GOOGLE_REFRESH_TOKEN.

  7. Add the GOOGLE_REFRESH_TOKEN to your .env file.

  8. Build the server:

    npm run build

šŸ”Œ Connecting to an MCP Client

Claude Desktop

Add the following to your claude_desktop_config.json (usually found at ~/Library/Application Support/Claude/claude_desktop_config.json on macOS):

{
  "mcpServers": {
    "google-services": {
      "command": "node",
      "args": [
        "/absolute/path/to/google-mcp-server/build/index.js"
      ],
      "env": {
        "GOOGLE_CLIENT_ID": "your_client_id",
        "GOOGLE_CLIENT_SECRET": "your_client_secret",
        "GOOGLE_REFRESH_TOKEN": "your_refresh_token",
        "GOOGLE_REDIRECT_URL": "http://localhost:3000/oauth2callback"
      }
    }
  }
}

Note: Replace /absolute/path/to/ with the actual path to this folder.


šŸ”§ Architecture

This server is built using the MCP SDK v2. It uses the stdio transport to communicate with the host agent. The architecture is designed to be highly modular. Adding a new Google service requires:

  1. Creating a new folder in src/tools/.

  2. Defining Zod schemas for inputs.

  3. Implementing the Google API logic.

  4. Calling the registration function in src/tools/index.ts.

It includes built-in exponential backoff for rate limiting and structured error handling for a robust agent experience.


āš ļø Troubleshooting

  • Authentication Error / Missing Token: Make sure you ran npm run authenticate and copied the refresh token into your .env file or Claude config.

  • Permission Denied (403): Ensure you added all 3 required scopes during the Google Cloud OAuth consent screen setup, and that the account you authenticated with has access to the target Google Doc.

  • Resource Not Found (404): Double check the document_id. It should be the string between /d/ and /edit in the Google Docs URL.

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.

  • Multiple Gmail accounts, editable Google Sheets & Docs for AI agents. Deny-by-default access rules.

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

Related MCP Servers