loading…
Search for a command to run...
loading…
Comprehensive Google Workspace MCP server with full support for Google Calendar, Drive, Gmail, and Docs, Forms, Chats, Slides and Sheets over stdio, Streamable
Comprehensive Google Workspace MCP server with full support for Google Calendar, Drive, Gmail, and Docs, Forms, Chats, Slides and Sheets over stdio, Streamable HTTP and SSE transports.
License: MIT Python 3.10+ PyPI PyPI Downloads Website
Full natural language control over Google Calendar, Drive, Gmail, Docs, Sheets, Slides, Forms, Tasks, Contacts, and Chat through all MCP clients, AI assistants and developer tools. Includes a full featured CLI for use with tools like Claude Code and Codex!
The most feature-complete Google Workspace MCP server, with Remote OAuth2.1 multi-user support and 1-click Claude installation. With native OAuth 2.1, stateless mode and external auth server support, it's the only Workspace MCP you can host for your whole organization centrally & securely!
|
⚡ Start Quick Start · Prerequisites Google Cloud · Credentials |
🧰 Tools All Tools · Tool Tiers CLI · Start Server |
🔌 Connect 1-Click Install · Claude Desktop Claude Code · VS Code · LM Studio |
🚀 Deploy OAuth 2.1 · Stateless External OAuth · Reverse Proxy |
📐 Develop Architecture · Dev Setup Security · License |
See it in action:
Workspace MCP is the single most complete MCP server that integrates all major Google Workspace services with AI assistants. It supports both single-user operation and multi-user authentication via OAuth 2.1, making it a powerful backend for custom applications. Built with FastMCP for optimal performance, featuring advanced authentication handling, service caching, and streamlined development patterns. The entire toolset is available for CLI usage supporting both local and remote instances.
Simplified Setup: can use Google Desktop OAuth clients for local runs - no redirect URIs or port configuration needed!
12 services — Gmail · Drive · Calendar · Docs · Sheets · Slides · Forms · Chat · Apps Script · Tasks · Contacts · Search
📧 Gmail — Complete email management, end-to-end coverage |
⚡ Apps Script — Cross-application workflow automation ✅ Tasks — Task & list management with hierarchy 🔐 Authentication & Security |
For Security Teams This server sends no data anywhere except Google's APIs, on behalf of the authenticated user, using your own OAuth client credentials. There is no telemetry, no usage reporting, no analytics, no license server, and no SaaS dependency. The entire data path is: your infrastructure → Google APIs.
Full dependency tree in |
For Legal & Procurement This project is MIT licensed — not "open core," not "source available," not "free with a CLA." There is no dual licensing, no commercial tier gating features, and no contributor license agreement.
The license is 21 lines and says what it means. |
Set credentials → pick a launch command → connect your client
💡 New to Workspace MCP? Check out the Interactive Quick Start Guide → with step-by-step setup, screenshots, and troubleshooting tips!
Confidential Client Quick Start
|
Secretless / Public OAuth 2.1 (PKCE) Quick Start
|
Credential setup → · All launch options → · Tier details →
| Variable | Purpose | |
|---|---|---|
| 🔐 Authentication | ||
GOOGLE_OAUTH_CLIENT_ID |
required | OAuth client ID from Google Cloud |
GOOGLE_OAUTH_CLIENT_SECRET |
OAuth client secret for confidential clients; optional for public OAuth 2.1 PKCE clients | |
OAUTHLIB_INSECURE_TRANSPORT |
required* | Set to 1 for development — allows http:// redirect |
USER_GOOGLE_EMAIL |
Default email for single-user auth | |
GOOGLE_CLIENT_SECRET_PATH |
Custom path to client_secret.json |
|
GOOGLE_MCP_CREDENTIALS_DIR |
Credential directory — default ~/.google_workspace_mcp/credentials |
|
| 🖥️ Server | ||
WORKSPACE_MCP_BASE_URI |
Base server URI (no port) — default http://localhost |
|
WORKSPACE_MCP_PORT |
Listening port — default 8000. Also controls the stdio-mode OAuth callback port. The PORT env var takes precedence if set. |
|
WORKSPACE_MCP_HOST |
Bind host — default 0.0.0.0 |
|
WORKSPACE_EXTERNAL_URL |
External URL for reverse proxy setups | |
WORKSPACE_ATTACHMENT_DIR |
Downloaded attachments dir and default trusted local attachment directory — default ~/.workspace-mcp/attachments/ |
|
WORKSPACE_MCP_URL |
Remote MCP endpoint URL for CLI | |
ALLOWED_FILE_DIRS |
Colon-separated allowlist for local file reads | |
| 🔑 OAuth 2.1 & Multi-User | ||
MCP_ENABLE_OAUTH21 |
true to enable OAuth 2.1 multi-user support |
|
EXTERNAL_OAUTH21_PROVIDER |
true for external OAuth flow with bearer tokens |
|
WORKSPACE_MCP_STATELESS_MODE |
true for stateless container-friendly operation |
|
GOOGLE_OAUTH_REDIRECT_URI |
Override OAuth callback URL — default auto-constructed | |
OAUTH_CUSTOM_REDIRECT_URIS |
Comma-separated additional redirect URIs | |
OAUTH_ALLOWED_ORIGINS |
Comma-separated additional CORS origins | |
WORKSPACE_MCP_OAUTH_PROXY_STORAGE_BACKEND |
memory, disk, or valkey — see storage backends |
|
FASTMCP_SERVER_AUTH_GOOGLE_JWT_SIGNING_KEY |
Custom encryption key for OAuth proxy storage; required for public OAuth 2.1 clients when GOOGLE_OAUTH_CLIENT_SECRET is omitted |
|
WORKSPACE_MCP_ALLOWED_CLIENT_REDIRECT_URIS |
Comma-separated allowlist of redirect URIs that dynamically-registered OAuth clients may use. Default is unset (any URI permitted, per DCR). Supports FastMCP's glob patterns (*, *.example.com) |
|
| 🗄️ Credential Store | ||
WORKSPACE_MCP_CREDENTIAL_STORE_BACKEND |
local_directory (default) or gcs — see credential store system |
|
WORKSPACE_MCP_CREDENTIALS_DIR |
Directory for the local_directory backend |
|
GOOGLE_MCP_CREDENTIALS_DIR |
Backward-compatible alias for WORKSPACE_MCP_CREDENTIALS_DIR |
|
WORKSPACE_MCP_GCS_BUCKET |
Required when backend is gcs — GCS bucket name |
|
WORKSPACE_MCP_GCS_PREFIX |
Optional object-name prefix for the gcs backend |
|
WORKSPACE_MCP_GCS_REQUIRE_CMEK |
true to require a bucket default KMS key at startup (fails fast if unset) |
|
| 🔧 Service Account | ||
GOOGLE_SERVICE_ACCOUNT_KEY_FILE |
Path to service account JSON key file (domain-wide delegation) | |
GOOGLE_SERVICE_ACCOUNT_KEY_JSON |
Inline service account JSON key (alternative to file) | |
| 🔍 Custom Search | ||
GOOGLE_PSE_API_KEY |
API key for Programmable Search Engine | |
GOOGLE_PSE_ENGINE_ID |
Search Engine ID for PSE |
*Required for development only. Claude Desktop stores credentials securely in the OS keychain — set them once in the extension pane.
.dxtbundles server, deps & manifest — download → double-click → done. No terminal, no JSON editing.
google_workspace_mcp.dxt from ReleasesPython 3.10+ · uv/uvx · Google Cloud Project with OAuth 2.0 credentials
If you want the GCS credential store backend, install the optional dependency first:
uv sync --extra gcs
# or
pip install "workspace-mcp[gcs]"
Create Project — Open Console → → Create new project
Create OAuth Credentials — APIs & Services → Credentials → Create Credentials → OAuth Client ID
Enable APIs — APIs & Services → Library, then enable each service:
| Calendar | Drive | Gmail | Docs |
| Sheets | Slides | Forms | Tasks |
| Chat | People | Custom Search | Apps Script |
Set Credentials — see Environment Variable Reference above, or:
export GOOGLE_OAUTH_CLIENT_ID="your-client-id"
export GOOGLE_OAUTH_CLIENT_SECRET="your-secret"
For public OAuth 2.1 PKCE clients, omit GOOGLE_OAUTH_CLIENT_SECRET and set FASTMCP_SERVER_AUTH_GOOGLE_JWT_SIGNING_KEY instead.
1. Create Search Engine
|
2. Get API Key
|
3. Set Variables
Configure in environment |
≡ Quick Setup Guide ← Step-by-step instructionsComplete Setup Process:
|
||
📌 Transport Mode Guidance: Use streamable HTTP mode (
--transport streamable-http) for all modern MCP clients including Claude Code, VS Code MCP, and MCP Inspector. Stdio mode is only for clients with incomplete MCP specification support.
▶ Legacy Mode
⚠️ Stdio mode (incomplete MCP clients only) |
◆ HTTP Mode (Recommended)
✅ Full MCP spec compliance & OAuth 2.1 |
@ Single User
Simplified authentication ⚠️ Cannot be used with OAuth 2.1 mode |
◆ Advanced Options ← Tool selection, tiers & Docker▶ Selective Tool Loading
🔒 Read-Only Mode
Read-only mode provides secure, restricted access by:
🔐 Granular Permissions
Granular permissions mode provides service-by-service scope control:
★ Tool Tiers
◆ Docker Deployment
Available Services: |
||
The workspace-cli command lists tools and calls them against a running server — with encrypted, disk-backed OAuth token caching so you only authenticate once. On first run it opens a browser for Google consent; subsequent runs reuse the cached tokens automatically.
Tokens are stored encrypted at ~/.workspace-mcp/cli-tokens/ using a Fernet key auto-generated at ~/.workspace-mcp/.cli-encryption-key.
▶ List Tools
View all available tools |
◆ Call a Tool
Execute a tool with key=value arguments |
Set URL for remote endpoints with --url or the WORKSPACE_MCP_URL environment variable.
The upstream FastMCP CLI is also bundled and provides additional commands for schema inspection, client installation, and editor discovery. Note that fastmcp uses in-memory token storage, so each invocation may re-trigger the OAuth flow.
fastmcp inspect fastmcp_server.py # print tools, resources, prompts
fastmcp install claude-code fastmcp_server.py # one-command client setup
fastmcp install cursor fastmcp_server.py
fastmcp discover # find servers configured in editors
See fastmcp --help or the FastMCP CLI docs for the full command reference.
The server organizes tools into three progressive tiers for simplified deployment. Choose a tier that matches your usage needs and API quota requirements.
Available Tiers● Core ( ● Extended ( ● Complete ( |
Important Notes▶ Start with |
# Basic tier selection
uv run main.py --tool-tier core # Start with essential tools only
uv run main.py --tool-tier extended # Expand to include management features
uv run main.py --tool-tier complete # Enable all available functionality
# Selective service loading with tiers
uv run main.py --tools gmail drive --tool-tier core # Core tools for specific services
uv run main.py --tools gmail --tool-tier extended # Extended Gmail functionality only
uv run main.py --tools docs sheets --tool-tier complete # Full access to Docs and Sheets
# Combine tier selection with granular permission levels
uv run main.py --permissions gmail:organize drive:full --tool-tier core
🚀 Environment Variables
Best for production |
📁 File-based
Traditional method |
⚡ .env File
Best for development |
📖 Credential Loading Details ← Understanding priority & best practicesLoading Priority
Why Environment Variables?
|
||
Note: All tools support automatic authentication via
@require_google_service()decorators with 30-minute service caching.
📖 Looking for detailed parameters? Visit the Complete Documentation → for comprehensive tool reference, examples, and API guides!
| Tool | Tier | Description |
|---|---|---|
list_calendars |
Core | List accessible calendars |
get_events |
Core | Retrieve events with time range filtering |
manage_event |
Core | Create, update, or delete calendar events |
create_calendar |
Extended | Create a new secondary Google Calendar |
query_freebusy |
Extended | Query free/busy information for calendars |
manage_out_of_office |
Extended | Create, list, update, or delete Out of Office events |
manage_focus_time |
Extended | Create, list, update, or delete Focus Time events |
| Tool | Tier | Description |
|---|---|---|
search_drive_files |
Core | Search files with query syntax |
get_drive_file_content |
Core | Read file content (Office, PDF, image) |
get_drive_file_download_url |
Core | Download Drive files to local disk |
create_drive_file |
Core | Create files or fetch from URLs |
create_drive_folder |
Core | Create empty folders in Drive or shared drives |
import_to_google_doc |
Core | Import files (MD, DOCX, HTML, etc.) as Google Docs |
get_drive_shareable_link |
Core | Get shareable links for a file |
list_drive_items |
Extended | List folder contents |
copy_drive_file |
Extended | Copy existing files (templates) with optional renaming |
update_drive_file |
Extended | Update file metadata, move between folders |
manage_drive_access |
Extended | Grant, update, revoke permissions, and transfer ownership |
set_drive_file_permissions |
Extended | Set link sharing and file-level sharing settings |
get_drive_file_permissions |
Complete | Get detailed file permissions |
check_drive_file_public_access |
Complete | Check public sharing status |
| Tool | Tier | Description |
|---|---|---|
search_gmail_messages |
Core | Search with Gmail operators |
get_gmail_message_content |
Core | Retrieve message content |
get_gmail_messages_content_batch |
Core | Batch retrieve message content |
send_gmail_message |
Core | Send emails |
get_gmail_thread_content |
Extended | Get full thread content |
modify_gmail_message_labels |
Extended | Modify message labels |
list_gmail_labels |
Extended | List available labels |
list_gmail_filters |
Extended | List Gmail filters |
manage_gmail_label |
Extended | Create/update/delete labels |
manage_gmail_filter |
Extended | Create or delete Gmail filters |
draft_gmail_message |
Extended | Create drafts |
get_gmail_threads_content_batch |
Complete | Batch retrieve thread content |
batch_modify_gmail_message_labels |
Complete | Batch modify labels |
start_google_auth |
Complete | Legacy OAuth 2.0 auth (disabled when OAuth 2.1 is enabled) |
Both send_gmail_message and draft_gmail_message support attachments via two methods:
Option 1: File Path (local server only)
attachments=[{"path": "/path/to/report.pdf"}]
Reads file from disk, auto-detects MIME type. Optional filename override.
Option 2: Base64 Content (works everywhere)
attachments=[{
"filename": "report.pdf",
"content": "JVBERi0xLjQK...", # base64-encoded
"mime_type": "application/pdf" # optional
}]
⚠️ Centrally Hosted Servers: When the MCP server runs remotely (cloud, shared instance), it cannot access your local filesystem. Use Option 2 with base64-encoded content. Your MCP client must encode files before sending.
When downloading Gmail attachments (get_gmail_attachment_content) or Drive files (get_drive_file_download_url), files are saved to a persistent local directory rather than a temporary folder in the working directory.
Default location: ~/.workspace-mcp/attachments/
Files are saved with their original filename plus a short UUID suffix for uniqueness (e.g., invoice_a1b2c3d4.pdf). In stdio mode, the tool returns the absolute file path for direct filesystem access. In HTTP mode, it returns a download URL via the /attachments/{file_id} endpoint.
To customize the storage directory:
export WORKSPACE_ATTACHMENT_DIR="/path/to/custom/dir"
Saved files expire after 1 hour and are cleaned up automatically.
| Tool | Tier | Description |
|---|---|---|
get_doc_content |
Core | Extract document text |
create_doc |
Core | Create new documents |
modify_doc_text |
Core | Insert, replace, and richly format text with tab/segment targeting, append-to-segment support, advanced typography, and link management |
search_docs |
Extended | Find documents by name |
find_and_replace_doc |
Extended | Find and replace text |
list_docs_in_folder |
Extended | List docs in folder |
insert_doc_elements |
Extended | Add tables, lists, page breaks |
update_paragraph_style |
Extended | Apply advanced paragraph styling including headings, spacing, direction, pagination controls, shading, and bulleted/numbered/checkbox lists with nesting |
get_doc_as_markdown |
Extended | Export document as formatted Markdown with optional comments |
insert_doc_image |
Complete | Insert images from Drive/URLs |
update_doc_headers_footers |
Complete | Create or update headers and footers with correct segment-aware writes |
batch_update_doc |
Complete | Execute atomic multi-step Docs API operations including named ranges, section breaks, document/section layout, header/footer creation, segment-aware inserts, images, tables, and rich formatting |
inspect_doc_structure |
Complete | Analyze document structure, including safe insertion points, tables, section breaks, headers/footers, and named ranges |
export_doc_to_pdf |
Extended | Export document to PDF |
create_table_with_data |
Complete | Create data tables |
debug_table_structure |
Complete | Debug table issues |
list_document_comments |
Complete | List all document comments |
manage_document_comment |
Complete | Create, reply to, or resolve comments |
manage_doc_tab |
Complete | Create, rename, delete, or populate tabs from markdown |
| Tool | Tier | Description |
|---|---|---|
read_sheet_values |
Core | Read cell ranges |
modify_sheet_values |
Core | Write/update/clear cells |
create_spreadsheet |
Core | Create new spreadsheets |
list_spreadsheets |
Extended | List accessible spreadsheets |
get_spreadsheet_info |
Extended | Get spreadsheet metadata |
format_sheet_range |
Extended | Apply colors, number formats, text wrapping, alignment, bold/italic, font size |
list_sheet_tables |
Extended | List structured tables with IDs, names, ranges, and columns |
create_sheet |
Complete | Add sheets to existing files |
append_table_rows |
Complete | Append rows to a structured table, auto-extending the table range |
list_spreadsheet_comments |
Complete | List all spreadsheet comments |
manage_spreadsheet_comment |
Complete | Create, reply to, or resolve comments |
manage_conditional_formatting |
Complete | Add, update, or delete conditional formatting rules |
| Tool | Tier | Description |
|---|---|---|
create_presentation |
Core | Create new presentations |
get_presentation |
Core | Retrieve presentation details |
batch_update_presentation |
Extended | Apply multiple updates |
get_page |
Extended | Get specific slide information |
get_page_thumbnail |
Extended | Generate slide thumbnails |
list_presentation_comments |
Complete | List all presentation comments |
manage_presentation_comment |
Complete | Create, reply to, or resolve comments |
| Tool | Tier | Description |
|---|---|---|
create_form |
Core | Create new forms |
get_form |
Core | Retrieve form details & URLs |
set_publish_settings |
Complete | Configure form settings |
get_form_response |
Complete | Get individual responses |
list_form_responses |
Extended | List all responses with pagination |
batch_update_form |
Complete | Apply batch updates (questions, settings) |
| Tool | Tier | Description |
|---|---|---|
list_tasks |
Core | List tasks with filtering |
get_task |
Core | Retrieve task details |
manage_task |
Core | Create, update, delete, or move tasks |
list_task_lists |
Complete | List task lists |
get_task_list |
Complete | Get task list details |
manage_task_list |
Complete | Create, update, delete task lists, or clear completed tasks |
| Tool | Tier | Description |
|---|---|---|
search_contacts |
Core | Search contacts by name, email, phone |
get_contact |
Core | Retrieve detailed contact info |
list_contacts |
Core | List contacts with pagination |
manage_contact |
Core | Create, update, or delete contacts |
list_contact_groups |
Extended | List contact groups/labels |
get_contact_group |
Extended | Get group details with members |
manage_contacts_batch |
Complete | Batch create, update, or delete contacts |
manage_contact_group |
Complete | Create, update, delete groups, or modify membership |
| Tool | Tier | Description |
|---|---|---|
list_spaces |
Extended | List chat spaces/rooms |
get_messages |
Core | Retrieve space messages |
send_message |
Core | Send messages to spaces |
search_messages |
Core | Search across chat history |
create_reaction |
Core | Add emoji reaction to a message |
download_chat_attachment |
Extended | Download attachment from a chat message |
| Tool | Tier | Description |
|---|---|---|
search_custom |
Core | Perform web searches (supports site restrictions via sites parameter) |
get_search_engine_info |
Complete | Retrieve search engine metadata |
| Tool | Tier | Description |
|---|---|---|
list_script_projects |
Core | List accessible Apps Script projects |
get_script_project |
Core | Get complete project with all files |
get_script_content |
Core | Retrieve specific file content |
create_script_project |
Core | Create new standalone or bound project |
update_script_content |
Core | Update or create script files |
run_script_function |
Core | Execute function with parameters |
list_deployments |
Extended | List all project deployments |
manage_deployment |
Extended | Create, update, or delete script deployments |
list_script_processes |
Extended | View recent executions and status |
Tool Tier Legend:
● Core — Essential tools for basic functionality · Minimal API usage · Getting started
● Extended — Core + additional features · Regular usage · Expanded capabilities
● Complete — All available tools including advanced features · Power users · Full API access
The server supports two transport modes:
⚠️ Important: Stdio mode is a legacy fallback for clients that don't properly implement the MCP specification with OAuth 2.1 and streamable HTTP support. Claude Code and other modern MCP clients should use streamable HTTP mode (
--transport streamable-http) for proper OAuth flow and multi-user support.
In general, you should use the one-click DXT installer package for Claude Desktop.
If you are unable to for some reason, you can configure it manually via claude_desktop_config.json
Manual Claude Configuration (Alternative)
Open Claude Desktop Settings → Developer → Edit Config
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.jsonAdd the server configuration:
{
"mcpServers": {
"google_workspace": {
"command": "uvx",
"args": ["workspace-mcp"],
"env": {
"GOOGLE_OAUTH_CLIENT_ID": "your-client-id",
"GOOGLE_OAUTH_CLIENT_SECRET": "your-secret",
"OAUTHLIB_INSECURE_TRANSPORT": "1"
}
}
}
}
Add a new MCP server in LM Studio (Settings → MCP Servers) using the same JSON format:
{
"mcpServers": {
"google_workspace": {
"command": "uvx",
"args": ["workspace-mcp"],
"env": {
"GOOGLE_OAUTH_CLIENT_ID": "your-client-id",
"GOOGLE_OAUTH_CLIENT_SECRET": "your-secret",
"OAUTHLIB_INSECURE_TRANSPORT": "1",
}
}
}
}
If you’re developing, deploying to servers, or using another MCP-capable client, keep reading.
# Requires Python 3.10+ and uvx
# First, set credentials (see Credential Configuration above)
uvx workspace-mcp --tool-tier core # or --tools gmail drive calendar
Note: Configure OAuth credentials before running. Supports environment variables,
.envfile, orclient_secret.json.
# Install everything needed for linting, tests, and release tooling
uv sync --group dev
# Run the same linter that git hooks invoke automatically
uv run ruff check .
# Execute the full test suite (async fixtures require pytest-asyncio)
uv run pytest
uv sync --group test installs only the testing stack if you need a slimmer environment.uv run main.py --transport streamable-http launches the server with your checked-out code for manual verification.dev group because pre-push hooks call ruff check automatically—run it locally before committing to avoid hook failures.The server includes OAuth 2.1 support for bearer token authentication, enabling multi-user session management. OAuth 2.1 automatically reuses your existing GOOGLE_OAUTH_CLIENT_ID and, for confidential clients, GOOGLE_OAUTH_CLIENT_SECRET credentials - no additional Google-side configuration needed. Public PKCE clients are also supported: if you omit GOOGLE_OAUTH_CLIENT_SECRET, set FASTMCP_SERVER_AUTH_GOOGLE_JWT_SIGNING_KEY explicitly.
When to use OAuth 2.1:
⚠️ Important: Mutually exclusive authentication modes
OAuth 2.1 mode (MCP_ENABLE_OAUTH21=true) cannot be used together with --single-user or service account mode:
Choose one authentication method - combining incompatible modes will result in a startup error.
Enabling OAuth 2.1:
To enable OAuth 2.1, set the MCP_ENABLE_OAUTH21 environment variable to true.
# OAuth 2.1 requires HTTP transport mode
export MCP_ENABLE_OAUTH21=true
uv run main.py --transport streamable-http
If MCP_ENABLE_OAUTH21 is not set to true, the server will use legacy authentication, which is suitable for clients that do not support OAuth 2.1.
FastMCP ships a native GoogleProvider that we now rely on directly. It solves the two tricky parts of using Google OAuth with MCP clients:
Dynamic Client Registration: Google still doesn't support OAuth 2.1 DCR, but the FastMCP provider exposes the full DCR surface and forwards registrations to Google using your fixed credentials. MCP clients register as usual and the provider hands them your Google client ID and, when configured, client secret under the hood.
CORS & Browser Compatibility: The provider includes an OAuth proxy that serves all discovery, authorization, and token endpoints with proper CORS headers. We no longer maintain custom /oauth2/* routes—the provider handles the upstream exchanges securely and advertises the correct metadata to clients.
The result is a leaner server that still enables any OAuth 2.1 compliant client (including browser-based ones) to authenticate through Google without bespoke code.
Restricting DCR client redirect URIs:
By default, any client going through Dynamic Client Registration can declare any redirect_uri. For publicly-exposed deployments, this is a phishing vector — an attacker can register a client with a redirect_uri they control and harvest authorization codes from tricked users. Set WORKSPACE_MCP_ALLOWED_CLIENT_REDIRECT_URIS to a comma-separated allowlist of permitted URIs:
# Public deployment — restrict to Claude's hosted OAuth callbacks
export WORKSPACE_MCP_ALLOWED_CLIENT_REDIRECT_URIS="https://claude.ai/api/mcp/auth_callback,https://claude.com/api/mcp/auth_callback"
# Add Claude Code CLI (loopback redirects on ephemeral ports)
export WORKSPACE_MCP_ALLOWED_CLIENT_REDIRECT_URIS="https://claude.ai/api/mcp/auth_callback,https://claude.com/api/mcp/auth_callback,http://localhost:*/callback,http://127.0.0.1:*/callback"
Patterns use FastMCP's matcher: * wildcards any port or path component; *.example.com matches subdomains. Leaving the variable unset preserves the default DCR behaviour (any URI accepted), which is appropriate for local development but unsafe for public deployments.
The server supports a stateless mode designed for containerized environments where file system writes should be avoided:
Enabling Stateless Mode:
# Stateless mode requires OAuth 2.1 to be enabled
export MCP_ENABLE_OAUTH21=true
export WORKSPACE_MCP_STATELESS_MODE=true
uv run main.py --transport streamable-http
Key Features:
Requirements:
MCP_ENABLE_OAUTH21=trueThis mode is ideal for:
MCP Inspector: No additional configuration needed with desktop OAuth client.
Claude Code: No additional configuration needed with desktop OAuth client.
The server supports pluggable storage backends for OAuth proxy state management via FastMCP 2.13.0+. Choose a backend based on your deployment needs.
Available Backends:
| Backend | Best For | Persistence | Multi-Server |
|---|---|---|---|
| Memory | Development, testing | ❌ | ❌ |
| Disk | Single-server production | ✅ | ❌ |
| Valkey/Redis | Distributed production | ✅ | ✅ |
Configuration:
# Memory storage (fast, no persistence)
export WORKSPACE_MCP_OAUTH_PROXY_STORAGE_BACKEND=memory
# Disk storage (persists across restarts)
export WORKSPACE_MCP_OAUTH_PROXY_STORAGE_BACKEND=disk
export WORKSPACE_MCP_OAUTH_PROXY_DISK_DIRECTORY=~/.fastmcp/oauth-proxy
# Valkey/Redis storage (distributed, multi-server)
export WORKSPACE_MCP_OAUTH_PROXY_STORAGE_BACKEND=valkey
export WORKSPACE_MCP_OAUTH_PROXY_VALKEY_HOST=redis.example.com
export WORKSPACE_MCP_OAUTH_PROXY_VALKEY_PORT=6379
Disk support requires
workspace-mcp[disk](orpy-key-value-aio[disk]) when installing from source. The official Docker image includes thediskextra by default. Valkey support is optional. Installworkspace-mcp[valkey](orpy-key-value-aio[valkey]) only if you enable the Valkey backend. Windows: buildingvalkey-glidefrom source requires MSVC C++ build tools with C11 support. If you seeaws-lc-sysC11 errors, setCFLAGS=/std:c11.
| Variable | Default | Description |
|---|---|---|
WORKSPACE_MCP_OAUTH_PROXY_VALKEY_HOST |
localhost | Valkey/Redis host |
WORKSPACE_MCP_OAUTH_PROXY_VALKEY_PORT |
6379 | Port (6380 auto-enables TLS) |
WORKSPACE_MCP_OAUTH_PROXY_VALKEY_DB |
0 | Database number |
WORKSPACE_MCP_OAUTH_PROXY_VALKEY_USE_TLS |
auto | Enable TLS (auto if port 6380) |
WORKSPACE_MCP_OAUTH_PROXY_VALKEY_USERNAME |
- | Authentication username |
WORKSPACE_MCP_OAUTH_PROXY_VALKEY_PASSWORD |
- | Authentication password |
WORKSPACE_MCP_OAUTH_PROXY_VALKEY_REQUEST_TIMEOUT_MS |
5000 | Request timeout for remote hosts |
WORKSPACE_MCP_OAUTH_PROXY_VALKEY_CONNECTION_TIMEOUT_MS |
10000 | Connection timeout for remote hosts |
Encryption: Disk and Valkey storage are encrypted with Fernet. The encryption key is derived from FASTMCP_SERVER_AUTH_GOOGLE_JWT_SIGNING_KEY if set, otherwise from GOOGLE_OAUTH_CLIENT_SECRET. Public OAuth 2.1 client setups without a client secret must set FASTMCP_SERVER_AUTH_GOOGLE_JWT_SIGNING_KEY.
The server supports an external OAuth 2.1 provider mode for scenarios where authentication is handled by an external system. In this mode, the MCP server does not manage the OAuth flow itself but expects valid bearer tokens in the Authorization header of tool calls.
Enabling External OAuth 2.1 Provider Mode:
# External OAuth provider mode requires OAuth 2.1 to be enabled
export MCP_ENABLE_OAUTH21=true
export EXTERNAL_OAUTH21_PROVIDER=true
uv run main.py --transport streamable-http
How It Works:
initialize and tools/list) require a valid Bearer token, following the standard OAuth 2.1 flow. Unauthenticated requests receive a 401 with resource metadata pointing to Google's authorization server.ya29.*)/.well-known/oauth-protected-resource (RFC 9728) advertising Google as the authorization server and the required scopesKey Features:
/authorize, /token, or /register endpoints — only resource metadataAuthorization: Bearer <token> headersWORKSPACE_MCP_STATELESS_MODE=trueRequirements:
MCP_ENABLE_OAUTH21=trueGOOGLE_OAUTH_CLIENT_ID, optional GOOGLE_OAUTH_CLIENT_SECRET)Use Cases:
WARNING: This mode uses Google Workspace domain-wide delegation, which grants the service account the ability to impersonate any user in your domain for the configured scopes. This is powerful and dangerous — do not use this unless you fully understand the security implications. A misconfigured service account with broad scopes can read, modify, and delete data across every user in your organization. Only use this in tightly controlled environments where you know exactly what you're doing.
Service account mode allows the server to authenticate using a Google Cloud service account with domain-wide delegation instead of interactive OAuth flows. The service account impersonates a single configured domain user for all API calls.
When to use service account mode:
Enabling Service Account Mode:
# Option 1: Key file on disk
export GOOGLE_SERVICE_ACCOUNT_KEY_FILE="/path/to/service-account-key.json"
export USER_GOOGLE_EMAIL="[email protected]"
uv run main.py
# Option 2: Inline JSON key (e.g., from a secret manager)
export GOOGLE_SERVICE_ACCOUNT_KEY_JSON='{"type":"service_account","project_id":"...","private_key":"...","client_email":"..."}'
export USER_GOOGLE_EMAIL="[email protected]"
uv run main.py
Prerequisites:
USER_GOOGLE_EMAIL set to the domain user the service account will impersonateIncompatibilities:
--single-user modeMCP_ENABLE_OAUTH21=trueGOOGLE_SERVICE_ACCOUNT_KEY_FILE or GOOGLE_SERVICE_ACCOUNT_KEY_JSON, not bothKey Behaviors:
USER_GOOGLE_EMAIL — any email addresses supplied in tool calls (e.g., user_email parameters) are ignored. This differs from OAuth modes where each user authenticates separately.✅ Recommended: VS Code MCP extension properly supports the full MCP specification. Always use HTTP transport mode for proper OAuth 2.1 authentication.
{
"servers": {
"google-workspace": {
"url": "http://localhost:8000/mcp/",
"type": "http"
}
}
}
Note: Make sure to start the server with --transport streamable-http when using VS Code MCP.
✅ Recommended: Claude Code is a modern MCP client that properly supports the full MCP specification. Always use HTTP transport mode with Claude Code for proper OAuth 2.1 authentication and multi-user support.
# Start the server in HTTP mode first
uv run main.py --transport streamable-http
# Then add to Claude Code
claude mcp add --transport http workspace-mcp http://localhost:8000/mcp
# Optional: install the bundled Claude skill for better Workspace tool routing
mkdir -p ~/.claude/skills
ln -s "$(pwd)/skills/managing-google-workspace" ~/.claude/skills/managing-google-workspace
Or copy skills/managing-google-workspace into ~/.claude/skills/managing-google-workspace if you prefer not to symlink it.
If you're running the MCP server behind a reverse proxy (nginx, Apache, Cloudflare, etc.), you have two configuration options:
Problem: When behind a reverse proxy, the server constructs OAuth URLs using internal ports (e.g., http://localhost:8000) but external clients need the public URL (e.g., https://your-domain.com).
Solution 1: Set WORKSPACE_EXTERNAL_URL for all OAuth endpoints:
# This configures all OAuth endpoints to use your external URL
export WORKSPACE_EXTERNAL_URL="https://your-domain.com"
Solution 2: Set GOOGLE_OAUTH_REDIRECT_URI for just the callback:
# This only overrides the OAuth callback URL
export GOOGLE_OAUTH_REDIRECT_URI="https://your-domain.com/oauth2callback"
You also have options for:
| OAUTH_CUSTOM_REDIRECT_URIS (optional) | Comma-separated list of additional redirect URIs |
| OAUTH_ALLOWED_ORIGINS (optional) | Comma-separated list of additional CORS origins |
Important:
WORKSPACE_EXTERNAL_URL when all OAuth endpoints should use the external URL (recommended for reverse proxy setups)GOOGLE_OAUTH_REDIRECT_URI when you only need to override the callback URL/oauth2callback, /oauth2/*, /.well-known/*) to the MCP server# Configure credentials first (see Credential Configuration section)
# Start with specific tools only
uvx workspace-mcp --tools gmail drive calendar tasks
# Start with tool tiers (recommended for most users)
uvx workspace-mcp --tool-tier core # Essential tools
uvx workspace-mcp --tool-tier extended # Core + additional features
uvx workspace-mcp --tool-tier complete # All tools
# Start in HTTP mode for debugging
uvx workspace-mcp --transport streamable-http
Requires Python 3.10+ and uvx. The package is available on PyPI.
For development or customization:
git clone https://github.com/taylorwilsdon/google_workspace_mcp.git
cd google_workspace_mcp
uv run main.py
Development Installation (For Contributors):
{
"mcpServers": {
"google_workspace": {
"command": "uv",
"args": [
"run",
"--directory",
"/path/to/repo/google_workspace_mcp",
"main.py"
],
"env": {
"GOOGLE_OAUTH_CLIENT_ID": "your-client-id",
"GOOGLE_OAUTH_CLIENT_SECRET": "your-secret",
"OAUTHLIB_INSECURE_TRANSPORT": "1"
}
}
}
}
If you need to use HTTP mode with Claude Desktop:
{
"mcpServers": {
"google_workspace": {
"command": "npx",
"args": ["mcp-remote", "http://localhost:8000/mcp"]
}
}
}
Note: Make sure to start the server with --transport streamable-http when using HTTP mode.
The server uses Google Desktop OAuth for simplified authentication:
When calling a tool:
google_workspace_mcp/
├── auth/ # Authentication system with decorators
├── core/ # MCP server and utilities
├── g{service}/ # Service-specific tools
├── main.py # Server entry point
├── client_secret.json # OAuth credentials (not committed)
└── pyproject.toml # Dependencies
from auth.service_decorator import require_google_service
@require_google_service("drive", "drive_read") # Service + scope group
async def your_new_tool(service, param1: str, param2: int = 10):
"""Tool description"""
# service is automatically injected and cached
result = service.files().list().execute()
return result # Return native Python objects
SCOPE_GROUPS for easy maintenance@require_multiple_services() for complex toolsThe server includes an abstract credential store API with pluggable backends for managing Google OAuth credentials:
Features:
CredentialStore base class defines standard operations (get, store, delete, list users)LocalDirectoryCredentialStore — plaintext JSON files protected by filesystem permissions (0o600 / 0o700)GCSCredentialStore — stores each user's credentials as an object in a Google Cloud Storage bucket. Supports atomic read-modify-write via generation preconditions, first-class Cloud IAM / Audit Logs integration, and transparent bucket-level CMEK encryption at restConfiguration:
# Install the optional dependency if you plan to use the GCS backend:
# uv sync --extra gcs
# or: pip install "workspace-mcp[gcs]"
#
# Select backend (default: local_directory). Supported: local_directory, gcs
export WORKSPACE_MCP_CREDENTIAL_STORE_BACKEND="gcs"
# --- local_directory options ---
export WORKSPACE_MCP_CREDENTIALS_DIR="/path/to/credentials"
# Backward-compatible alias:
export GOOGLE_MCP_CREDENTIALS_DIR="/path/to/credentials"
# Default directory locations (if no directory env var is set):
# - ~/.google_workspace_mcp/credentials (if home directory accessible)
# - ./.credentials (fallback)
# --- gcs options ---
export WORKSPACE_MCP_GCS_BUCKET="my-workspace-mcp-tokens" # required
export WORKSPACE_MCP_GCS_PREFIX="credentials/" # optional
export WORKSPACE_MCP_GCS_REQUIRE_CMEK="true" # optional; see below
Backend selection:
local_directory (default): Plaintext JSON records. Suitable for local development and single-user stdio mode.
Existing pre-URL-encoding local credential filenames remain readable during migration; new writes use the URL-encoded filename mapping unless a legacy file already exists for that user.gcs: Stores credentials as objects in a GCS bucket using the JSON API. Authenticates via Application Default Credentials — on Cloud Run this means the runtime service account needs roles/storage.objectUser (or equivalent) on the bucket. Does not support list_users() — designed for multi-user OAuth 2.1 mode where users are looked up individually by email.CMEK enforcement (gcs backend):
By default GCS encrypts objects with Google-managed keys. For customer-managed encryption, set a default KMS key on the bucket (e.g. via Terraform's google_storage_bucket.encryption.default_kms_key_name). All credentials written to the bucket will inherit the key transparently — no application-level key to manage.
To guard against accidentally deploying against a bucket without CMEK, set WORKSPACE_MCP_GCS_REQUIRE_CMEK=true. The store will verify the bucket has a default KMS key at startup and refuse to initialize otherwise. Note that this check reads bucket metadata, so the runtime service account additionally needs storage.buckets.get — grant roles/storage.bucketViewer on the bucket (or a custom role containing storage.buckets.get) in addition to the object-level role. roles/storage.objectUser alone covers only object operations.
Usage Example:
from auth.credential_store import get_credential_store, LocalDirectoryCredentialStore
# Get the global credential store instance
store = get_credential_store()
# Store credentials for a user
store.store_credential("[email protected]", credentials)
# Retrieve credentials
creds = store.get_credential("[email protected]")
# List all users with stored credentials (local_directory backend only;
# GCSCredentialStore intentionally does not support enumeration — use the
# upstream identity provider to enumerate users instead).
if isinstance(store, LocalDirectoryCredentialStore):
users = store.list_users()
The credential store automatically handles credential serialization, expiry parsing, and provides error handling for storage operations.
.env, client_secret.json or the .credentials/ directory to source control!http://localhost:8000/oauth2callback for development (requires OAUTHLIB_INSECURE_TRANSPORT=1). If another process is already using port 8000, set WORKSPACE_MCP_PORT to a free port to avoid conflicts — e.g. export WORKSPACE_MCP_PORT=8123. If you use a web/confidential OAuth client (not the recommended Desktop client), also update the redirect URI in Google Cloud Console to match the new port (e.g. http://localhost:8123/oauth2callback); Desktop and PKCE clients do not require this.file:// uploads) are restricted to the managed attachment directory by default. Override this with the ALLOWED_FILE_DIRS environment variable if you intentionally need broader access:# Colon-separated list of directories (semicolon on Windows) from which local file reads are permitted
export ALLOWED_FILE_DIRS="/home/user/documents:/data/shared"
The managed attachment directory is controlled by WORKSPACE_ATTACHMENT_DIR and remains allowed even when ALLOWED_FILE_DIRS is set. Regardless of the allowlist, access to sensitive paths (.env, .ssh/, .aws/, /etc/shadow, credential files, etc.) is always blocked.ALLOWED_FILE_DIRS unless you trust the client, the model behavior, and the data sources it can read.MIT License - see LICENSE file for details.
Validations: MCP Badge
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"taylorwilsdon-google-workspace-mcp": {
"command": "npx",
"args": []
}
}
}