Skip to main content

Google Workspace MCP — headless, service-account auth

A Model Context Protocol server that exposes 56 tools across 9 Google Workspace services — Calendar, Gmail, Drive, Docs, Sheets, Slides, Tasks, Forms, and Keep.

Unlike most Google Workspace MCP servers, this one needs no interactive OAuth flow, ever. Authentication is a service account with domain-wide delegation impersonating a Workspace user — the auth model designed for headless agents, CI pipelines and unattended automation. Set it up once, run it anywhere.

Tool inventory

Service Tools Examples
Calendar (7) list_calendars, list_calendar_events, create_calendar_event, update_calendar_event, delete_calendar_event, search_calendar_events, get_free_busy Create/update events, free/busy lookup
Gmail (11) list_gmail_labels, search_gmail, read_gmail_message, list_gmail_attachments, download_gmail_attachments, send_gmail, reply_to_gmail, create_gmail_draft, mark_gmail_read, mark_gmail_unread, delete_gmail_message Full mail workflow incl. attachments & "Send mail as" aliases
Drive (9) search_drive_files, read_drive_file, download_drive_file, create_drive_folder, share_drive_file, upload_drive_file, delete_drive_file, rename_drive_file, move_drive_file Upload text via content or binary via local_path; download files to disk via download_drive_file
Docs (5) read_google_doc, create_google_doc, append_to_google_doc, replace_text_in_google_doc, delete_google_doc
Sheets (6) read_google_sheet, write_google_sheet, append_to_google_sheet, create_google_sheet, clear_google_sheet, add_sheet_tab
Slides (5) read_google_slides, create_google_slides, add_slide_with_text, delete_slide, update_slide_text
Tasks (7) list_task_lists, list_tasks, create_task, complete_task, delete_task, update_task, create_task_list
Forms (3) create_google_form, read_google_form, read_form_responses
Keep (3) list_keep_notes, read_keep_note, create_keep_note

Setup

1. Google Cloud service account + domain-wide delegation

This server impersonates a real Workspace user through a service account:

  1. Create a GCP project and enable the APIs you need: Calendar, Gmail, Drive, Docs, Sheets, Slides, Tasks, Forms, Keep.

  2. Create a service account and enable domain-wide delegation on it (copy its Client ID).

  3. In Google Workspace Admin → Security → Access and data control → API controls → Domain-wide delegation, authorize the Client ID with these scopes:

    https://www.googleapis.com/auth/calendar
    https://www.googleapis.com/auth/calendar.events
    https://www.googleapis.com/auth/gmail.modify
    https://www.googleapis.com/auth/gmail.send
    https://www.googleapis.com/auth/drive
    https://www.googleapis.com/auth/documents
    https://www.googleapis.com/auth/spreadsheets
    https://www.googleapis.com/auth/presentations
    https://www.googleapis.com/auth/forms.body
    https://www.googleapis.com/auth/keep
    https://www.googleapis.com/auth/tasks
    
  4. Download the service account's JSON key.

Note: this auth model requires Google Workspace with admin access (domain-wide delegation). It does not work with consumer @gmail.com accounts.

2. Install

No clone needed — the package is on PyPI as google-workspace-headless-mcp:

# run directly with uvx (recommended for MCP servers)
uvx google-workspace-headless-mcp

# or install persistently with pipx / pip
pipx install google-workspace-headless-mcp

For development, clone this repo instead:

python3 -m venv .venv
.venv/bin/pip install -r requirements.txt

3. Configure environment

Variable Required Description
GOOGLE_APPLICATION_CREDENTIALS yes* Path to the service account key JSON. Defaults to ./service_account.json in the repo.
WORKSPACE_USER_EMAIL yes The Workspace user to impersonate (e.g. you@yourdomain.com).

Verify everything works:

export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service_account.json
export WORKSPACE_USER_EMAIL=you@yourdomain.com
uvx --from google-workspace-headless-mcp google-workspace-headless-mcp-verify

(the same script is available as verify_access.py inside a development clone)

4. Wire up your MCP client

{
  "mcpServers": {
    "google-workspace": {
      "command": "uvx",
      "args": ["google-workspace-headless-mcp"],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "/path/to/service_account.json",
        "WORKSPACE_USER_EMAIL": "you@yourdomain.com"
      }
    }
  }
}

If you installed with pipx or pip instead, use "command": "google-workspace-headless-mcp" with no args. In a development clone, point the command at .venv/bin/python with workspace_mcp_server.py as the argument.

Testing tools without a client

mcp_cli.py calls any tool over real MCP JSON-RPC:

.venv/bin/python mcp_cli.py list_calendars
.venv/bin/python mcp_cli.py upload_drive_file '{"file_name": "logo.psd", "local_path": "/tmp/logo.psd", "mime_type": "image/vnd.adobe.photoshop"}'

Tests

.venv/bin/pytest tests/ -v

test_workspace_access.py makes live API calls and is skipped unless WORKSPACE_USER_EMAIL and a key file are configured.

Requirements

Python 3.10+. Deps: fastmcp, google-api-python-client, google-auth, google-auth-httplib2, google-auth-oauthlib (see requirements.txt).

License

MIT — see LICENSE.

Metadata

Release files for google-workspace-headless-mcp 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for google-workspace-headless-mcp 1.0.0
File Size Uploaded Provenance Actions
google_workspace_headless_mcp-1.0.0.tar.gz 19.7 kB Without provenance Details for google_workspace_headless_mcp-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for google-workspace-headless-mcp 1.0.0
File Interpreter ABI Platform Actions
google_workspace_headless_mcp-1.0.0-py3-none-any.whl Python 3 none any Details for google_workspace_headless_mcp-1.0.0-py3-none-any.whl

Total release size: 39.6 kB

Release files / google_workspace_headless_mcp-1.0.0.tar.gz

Download URL google_workspace_headless_mcp-1.0.0.tar.gz
Size 19.7 kB
Tags Source
SHA-256 checksum
How to use checksums
4d8f8e4fc401c08e8d6ec9ef97c5d8ee5e2d51ee4d758af2c30eb26c90ce6dde
BLAKE2b-256 checksum
How to use checksums
18854064ba5e6aecae0f7d1b1989e7bc63dab099157bd7ddb34a93fc9b470d6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / google_workspace_headless_mcp-1.0.0-py3-none-any.whl

Download URL google_workspace_headless_mcp-1.0.0-py3-none-any.whl
Size 19.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ccd4e3eb8a7d725c9ce2ac0b1ebbce8097c747bb6bbbd64c80e3b95e93f2c078
BLAKE2b-256 checksum
How to use checksums
b503b89c61fa7209b1297b87aac49b496c1c36d64a19f9679b7c4e973f684d9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for google-workspace-headless-mcp 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page