Google Workspace MCP Server

1.19.0 · active · verified Thu Apr 16

Workspace-mcp is a comprehensive and highly performant Python server designed to integrate major Google Workspace services (Calendar, Gmail, Docs, Sheets, Slides, Drive, etc.) with AI assistants via the MCP (Multi-Client Protocol). It supports both single-user and multi-user authentication through OAuth 2.1, providing a powerful backend for natural language control over Google Workspace. The library is currently at version 1.19.0 and maintains an active release cadence with frequent updates and feature enhancements.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to set up environment variables for Google OAuth and then start the `workspace-mcp` server using the `uvx` CLI tool. It requires a Google Cloud Project with OAuth 2.0 credentials configured for a 'Desktop application' and the necessary Workspace APIs enabled. The server will run and expose Google Workspace tools to compatible MCP clients.

import os
import subprocess

# --- Step 1: Set up Google OAuth Credentials ---
# Create a Google Cloud Project, enable necessary APIs (e.g., Gmail API, Google Calendar API, Google Drive API).
# Configure the OAuth consent screen (External, add yourself as test user, add scopes).
# Create OAuth 2.0 credentials: Choose 'Desktop application' type.
# Note your Client ID and Client Secret. Set them as environment variables.
# For a web application, ensure redirect URIs and origins match your deployment.

# Replace with your actual Google OAuth Client ID and Secret
os.environ['GOOGLE_OAUTH_CLIENT_ID'] = os.environ.get('GOOGLE_OAUTH_CLIENT_ID', 'YOUR_GOOGLE_CLIENT_ID')
os.environ['GOOGLE_OAUTH_CLIENT_SECRET'] = os.environ.get('GOOGLE_OAUTH_CLIENT_SECRET', 'YOUR_GOOGLE_CLIENT_SECRET')

# Optional: For local legacy HTTP callback flows, may be required for certain setups.
# os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1'

# --- Step 2: Start the Google Workspace MCP Server ---
# 'uvx' is recommended for instant run. Ensure 'uv' is installed (`pip install uv`).
# '--transport streamable-http' is recommended for modern MCP clients.
# '--tool-tier core' or explicit '--tools gmail drive calendar' selects services.

print("Starting Google Workspace MCP Server...")
try:
    subprocess.run(
        ["uvx", "workspace-mcp", "--transport", "streamable-http", "--tool-tier", "core"],
        check=True
    )
except FileNotFoundError:
    print("Error: 'uvx' command not found. Please install 'uv' with `pip install uv`.")
except subprocess.CalledProcessError as e:
    print(f"Server exited with an error: {e}")

print("Server stopped.")

view raw JSON →