Skip to main content
Glama
mattgotteiner

Gmail Local MCP

Gmail Local MCP

Local stdio MCP server that mirrors the public Gmail MCP server tool surface while calling the Gmail REST API directly. It is intended as a temporary stand-in for https://gmailmcp.googleapis.com/mcp/v1.

Setup

  1. Follow Google's official Configure the Gmail MCP server guide to provision a Google Cloud project, enable the Gmail API and Gmail MCP API, configure the OAuth consent screen, and create a Google OAuth desktop client.

  2. Copy config.sample.json to config.json.

  3. Fill in oauth.clientId and oauth.clientSecret with the OAuth client values from the official provisioning flow, then set the official Gmail MCP scopes:

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

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

  4. Run npm install and npm run build.

config.json and .gmail-token.json are gitignored. On startup the server refreshes saved tokens when possible. If no token is present, or the token cannot be refreshed, it starts a localhost OAuth callback and opens the Google login page in your browser.

OAuth redirect URI

The local OAuth callback URL is:

http://127.0.0.1:<redirectPort>/oauth2callback

If you use a Google OAuth Web application client, set redirectPort in config.json to a fixed port and add that exact URL to the client's Authorized redirect URIs. For example, with "redirectPort": 3000, add:

http://127.0.0.1:3000/oauth2callback

The default sample uses "redirectPort": 0, which lets the OS choose an available port. That is convenient for a Google OAuth Desktop app client, but it is not suitable for a Web application client because the redirect URI must be registered exactly.

Related MCP server: gmail-mcp

Official remote Gmail MCP configuration

If you want to use Google's hosted Gmail MCP server instead of this local stdio stand-in, use the official server URL and OAuth configuration from Google's provisioning guide:

{
  "mcpServers": {
    "gmail": {
      "httpUrl": "https://gmailmcp.googleapis.com/mcp/v1",
      "oauth": {
        "enabled": true,
        "clientId": "OAUTH_CLIENT_ID",
        "clientSecret": "OAUTH_CLIENT_SECRET",
        "scopes": [
          "https://www.googleapis.com/auth/gmail.readonly",
          "https://www.googleapis.com/auth/gmail.compose"
        ]
      }
    }
  }
}

Replace OAUTH_CLIENT_ID and OAUTH_CLIENT_SECRET with the OAuth client values you created in Google Cloud.

MCP client configuration

Use stdio transport and point your client at the built server. Replace /path/to/gmail-local-mcp with the directory where you cloned or copied this repo.

GitHub Copilot CLI

Add this server to your Copilot CLI MCP server configuration:

{
  "mcpServers": {
    "gmail": {
      "command": "node",
      "args": [
        "/path/to/gmail-local-mcp/dist/src/index.js",
        "--config",
        "/path/to/gmail-local-mcp/config.json"
      ]
    }
  }
}

On Windows, use escaped backslashes in JSON paths, for example C:\\path\\to\\gmail-local-mcp\\dist\\src\\index.js.

For development, use npm run dev -- --config config.json.

Tools

The server exposes the same 10 tool names as the public Gmail MCP server:

create_draft, list_drafts, get_thread, search_threads, label_thread, unlabel_thread, list_labels, label_message, unlabel_message, and create_label.

Non-interactive testing

You can provide a short-lived access token without writing it to disk. In this mode, config.json is optional:

$env:GMAIL_ACCESS_TOKEN = "ya29..."
npm run e2e

The e2e script only calls read/list tools so it can run with the official Gmail MCP scope set.

License

This project is licensed under the MIT License.

Related MCP Connectors

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

  • A MCP server for Gmail that lets you search, read, and draft emails and replies.

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

  • MCP server for Nylas — read email, calendars, events and contacts, and send email or create events.

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    A local MCP server that provides tool-level access to Gmail, allowing Claude to search, read, send, and manage emails using the Gmail API.
    1
    MIT
  • F
    license
    A
    quality
    D
    maintenance
    Local stdio MCP server enabling Claude to send Gmail, search emails with attachment metadata, and download attachments to Google Drive.
    2
    3
    -
  • A
    license
    Not graded
    quality
    C
    maintenance
    Local MCP server providing Gmail tools (search, read, draft, send, trash) via Google's official API, integrated with GitHub Copilot CLI.
    MIT
  • A
    license
    A
    quality
    C
    maintenance
    A minimal MCP server for sending plain-text emails and managing Gmail user labels over stdio, using only gmail.send and gmail.labels OAuth scopes.
    4
    194 npm
    MIT