Google Workspace MCP server

Integrates Google Workspace APIs to enable tasks like sending emails, scheduling meetings, and managing documents in Gmail, Calendar, and Drive.
Back to servers
Setup instructions
Provider
Jean-Christophe Hoelt
Release date
Feb 25, 2025
Language
TypeScript
Stats
11 stars

This MCP Google Workspace server provides integration between AI assistants and Google services like Gmail and Calendar through the Model Context Protocol. It allows your assistant to read and manage emails, draft responses, view calendar events, and more.

Installation

Prerequisites

  • Node.js version 18 or higher
  • A Google Cloud project with Gmail and Calendar APIs enabled
  • OAuth 2.0 credentials for Google APIs

Setup Steps

  1. Clone the repository and install dependencies:

    git clone https://github.com/j3k0/mcp-google-workspace.git
    cd mcp-google-workspace
    npm install
    npm run build
    
  2. Create a .gauth.json file in the project root with your Google OAuth credentials:

    {
      "installed": {
        "client_id": "your_client_id",
        "project_id": "your_project_id",
        "auth_uri": "https://accounts.google.com/o/oauth2/auth",
        "token_uri": "https://oauth2.googleapis.com/token",
        "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
        "client_secret": "your_client_secret",
        "redirect_uris": ["http://localhost:4100/code"]
      }
    }
    
  3. Create a .accounts.json file to specify which Google accounts can use the server:

    {
      "accounts": [
        {
          "email": "[email protected]",
          "account_type": "personal",
          "extra_info": "Primary account with Family Calendar"
        }
      ]
    }
    

OAuth 2.0 Setup

  1. Go to the Google Cloud Console

  2. Create a project or select an existing one

  3. Enable Gmail API and Google Calendar API

  4. Create OAuth credentials (Desktop app or Web application)

  5. Add http://localhost:4100/code as an authorized redirect URI

  6. Ensure your app requests these OAuth scopes:

    openid
    https://mail.google.com/
    https://www.googleapis.com/auth/calendar
    https://www.googleapis.com/auth/userinfo.email
    

Configuration

Claude Desktop Integration

Configure Claude Desktop to use the MCP Google Workspace server:

On MacOS: Edit ~/Library/Application\ Support/Claude/claude_desktop_config.json

On Windows: Edit %APPDATA%/Claude/claude_desktop_config.json

For development/unpublished servers:

{
  "mcpServers": {
    "mcp-google-workspace": {
      "command": "<dir_to>/mcp-google-workspace/launch"
    }
  }
}

For published servers:

{
  "mcpServers": {
    "mcp-google-workspace": {
      "command": "npx",
      "args": [
        "mcp-google-workspace"
      ]
    }
  }
}

Usage

Starting the Server

Start the server with:

npm start

Optional arguments:

  • --gauth-file: Custom path to OAuth credentials (default: ./.gauth.json)
  • --accounts-file: Custom path to accounts configuration (default: ./.accounts.json)
  • --credentials-dir: Directory to store OAuth credentials (default: current directory)

On first run for each account, the server will:

  • Open a browser window for authentication
  • Listen on port 4100 for the OAuth callback
  • Store credentials for future use in .oauth2.{email}.json

Available Tools

Account Management

  • List Accounts: View all configured Google accounts with their metadata
    • Tools: gmail_list_accounts or calendar_list_accounts

Gmail Features

  • Query Emails: Search emails using Gmail's query syntax

    • Tool: gmail_query_emails
    • Examples: 'is:unread', 'from:[email protected]', 'newer_than:2d'
  • Get Email Content: Retrieve complete email content by ID

    • Tool: gmail_get_email
  • Bulk Get Emails: Retrieve multiple emails in one request

    • Tool: gmail_bulk_get_emails
  • Create Drafts: Create new email drafts

    • Tool: gmail_create_draft
  • Delete Drafts: Remove draft emails

    • Tool: gmail_delete_draft
  • Reply to Emails: Reply to existing emails

    • Tool: gmail_reply
    • Options to send immediately or save as draft
  • Handle Attachments: Download email attachments

    • Tools: gmail_get_attachment and gmail_bulk_save_attachments
  • Archive Emails: Move emails out of inbox

    • Tools: gmail_archive and gmail_bulk_archive

Calendar Features

  • List Calendars: View all accessible calendars

    • Tool: calendar_list
  • Get Events: Retrieve events in a date range

    • Tool: calendar_get_events
    • Supports multiple calendars and timezone customization
  • Create Events: Add new calendar events

    • Tool: calendar_create_event
    • Support for attendees, locations, and notifications
  • Delete Events: Remove calendar events

    • Tool: calendar_delete_event

Example Prompts

Try asking your assistant:

  • "Retrieve my latest unread messages"
  • "Search my emails from the Scrum Master"
  • "Write a response to Alice's last email and save it as a draft"
  • "What do I have on my agenda tomorrow?"
  • "Check my private account's Family agenda for next week"
  • "I need to plan an event with Tim for 2hrs next week. Suggest some time slots"

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "mcp-google-workspace" '{"command":"npx","args":["mcp-google-workspace"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "mcp-google-workspace": {
            "command": "npx",
            "args": [
                "mcp-google-workspace"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "mcp-google-workspace": {
            "command": "npx",
            "args": [
                "mcp-google-workspace"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later