Google Workspace MCP Server

repository·main·Indexed 25 days ago

https://github.com/taylorwilsdon/google_workspace_mcp

A Model Context Protocol (MCP) server enabling AI assistants to interact with Google Workspace services including Gmail, Drive, Docs, Sheets, Slides, Calendar, and Apps Script. It supports OAuth 2.1, stateless operation, and provides tools for managing Apps Script project lifecycles, including code modification and function execution. Version 1.22.2.

Tokens
35.1K
Snippets
45
Records
216
Agent score
84%

What's inside google_workspace_mcp

  1. Overview of Google Workspace MCP Server

    main

    Google Workspace MCP Server provides full natural language control over Google Workspace services through Model Context Protocol (MCP) clients, AI assistants, and developer tools. It supports 12 major services:

    • Gmail: Complete email management.
    • Drive: File operations including sharing, permissions, Office files, PDFs, and images.
    • Calendar: Full event management.
    • Docs: Fine-grained editing, formatting, and comments.
    • Sheets: Cell management, formatting, and conditional rules.
    • Slides: Presentation creation and content manipulation.
    • Forms: Creation, publishing, and response management.
    • Chat: Space management, messaging, and reactions.
    • Apps Script: Workflow automation (projects, deployments, versions, execution, debugging).
    • Tasks: Task and list management with hierarchy.
    • Contacts: People API with groups and batch operations.
    • Search: Programmable Search Engine integration.

    The server supports all Google account types (free and Workspace plans) and features native OAuth 2.1, stateless mode, and multi-user support.

  2. Run Workspace MCP in different transport modes

    main

    You can run the server using different transport protocols depending on your client requirements.

    Stdio (Default)

    Best for Claude Desktop and local MCP clients.

    uvx workspace-mcp

    HTTP (Streamable)

    For web interfaces, debugging, or multi-client setups. Access at http://localhost:8000/mcp/.

    uvx workspace-mcp --transport streamable-http

    Docker

    To run via Docker with HTTP transport:

    docker build -t workspace-mcp .
    docker run -p 8000:8000 \
      -e GOOGLE_OAUTH_CLIENT_ID="..." \
      -e GOOGLE_OAUTH_CLIENT_SECRET="..." \
      workspace-mcp --transport streamable-http
  3. Install and run Google Workspace MCP via CLI

    main

    You can run the Google Workspace MCP server using uvx. You can perform an instant run without installation, limit the server to specific services, or select a specific tool tier to manage the number of available tools.

    Instant run

    uvx workspace-mcp

    Run with specific services only

    uvx workspace-mcp --tools gmail drive calendar

    Run with a specific tool tier

    uvx workspace-mcp --tool-tier core
    uvx workspace-mcp
    
    # With specific tools only
    uvx workspace-mcp --tools gmail drive calendar
    
    # With tool tier
    uvx workspace-mcp --tool-tier core
  4. Enable OAuth 2.1 Authentication

    main

    To enable OAuth 2.1, set the MCP_ENABLE_OAUTH21 environment variable to true. Note that OAuth 2.1 requires using the streamable-http transport mode.

    If MCP_ENABLE_OAUTH21 is not set, the server uses legacy authentication. In streamable-http mode, legacy authentication binds to 127.0.0.1 by default. For remote or shared HTTP deployments, use OAuth 2.1.

    # OAuth 2.1 requires HTTP transport mode
    export MCP_ENABLE_OAUTH21=true
    uv run main.py --transport streamable-http
  5. Manage Apps Script Projects and Code

    main

    Use the following patterns to manage your Apps Script lifecycle via an AI agent:

    • List Projects: Use list_script_projects to see available projects and their IDs.
    • Inspect Code: Use get_script_project to retrieve the full project structure, including all files (e.g., .gs, .html, and appsscript.json).
    • Modify Code: Use update_script_content to add or modify JavaScript files within a project.
    • Execute: Use run_script_function to test functions in development mode or production deployments.
    • Deploy: Use create_deployment to create new versioned deployments for production use.
  6. Best practices for Google Calendar tools

    main

    Follow these guidelines when using the Google Calendar MCP tools:

    • Calendar IDs: Use list_calendars to find specific IDs. You can always use primary to refer to the user's main calendar.
    • Time Formats: Always use RFC 3339 for time parameters. Date-only strings (e.g., 2026-03-19) are interpreted as midnight UTC.
    • All-day Events: To create an all-day event, use date-only strings for both start_time and end_time. For an event on 20 March, use start_time="2026-03-20" and end_time="2026-03-21".
    • Attendee Formats: You can provide attendees as a simple list of email strings ["alice@example.com"] or as detailed objects [{"email": "alice@example.com", "optional": true}].
  7. Best practices for building and updating Google Forms

    main

    Building forms

    1. Call create_form to initialize the form.
    2. Call batch_update_form with createItem requests to add questions and content items.

    Updating existing questions

    Before modifying a form, call get_form first. This allows you to retrieve the specific item IDs needed for updateItem or deleteItem requests within batch_update_form.

    Checking responses

    Use list_form_responses to retrieve submissions. Because answers are keyed by question ID, cross-reference the response data with the output of get_form to map answers back to their human-readable questions.

  8. Authenticate in headless environments

    main

    When running E2E tests on a headless machine (e.g., SSH, WSL, or CI), follow this OAuth flow:

    1. Run the test script. It will print an authorization URL.
    2. Open that URL in a browser on any machine with a GUI.
    3. Complete the Google sign-in and authorization.
    4. After authorization, the browser will redirect to http://localhost/?code=... (the page will not load; this is expected).
    5. Copy the full URL from your browser's address bar.
    6. Paste that URL into the terminal prompt in your headless session.
  9. Install the Google Doc Layout Workflow skill

    main

    This skill is a Claude Code reusable prompt that guides AI agents through complex multi-step workflows to create well-formatted Google Docs. It prevents common formatting pitfalls like style cascading, index shifting, and list merging. To use this guidance, install it into your Claude skills directory:

    mkdir -p ~/.claude/skills/managing-google-workspace/references
    cp skills/managing-google-workspace/references/docs-layout-workflow.md ~/.claude/skills/managing-google-workspace/references/
  10. Best practices for Google Contacts

    main

    Avoid duplicates

    Use search_contacts to check whether a contact already exists before creating a new one. Search matches on name, email, and phone number.

    Batch organisation

    Use contact groups to organise contacts into categories. Create a group with manage_contact_group, then add contacts to it with the modify_members action.

    Extra context

    The notes field on a contact is a free-text area useful for storing context that does not fit into structured fields (e.g. how you met, preferred contact method).

  11. Setup Google Cloud Project for Apps Script MCP

    main

    Before using the Apps Script MCP tools, you must configure a Google Cloud project with the necessary APIs and credentials.

    1. Enable APIs

    Enable the following APIs in your Google Cloud Console:

    • Apps Script API (required for all operations)
    • Google Drive API (required for listing projects)

    2. Create OAuth Credentials

    1. Navigate to APIs & Services > Credentials.
    2. Click Create Credentials > OAuth client ID.
    3. Select Desktop application as the application type.
    4. Download the JSON file and save it as client_secret.json.
    1. Go to the OAuth consent screen settings.
    2. Add yourself as a test user (required for unverified apps).
    3. Ensure the required scopes are included (these are automatically requested by the tool tier).