google_workspace_mcp
Control Gmail, Google Calendar, Docs, Sheets, Slides, Chat, Forms, Tasks, Search & Drive with AI - Comprehensive Google Workspace / G Suite MCP Server & CLI Tool
Google Workspace MCP Server 
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!
Support for all free Google accounts (Gmail, Docs, Drive etc) & Google Workspace plans (Starter, Standard, Plus, Enterprise, Non Profit) with expanded app options like Chat & Spaces.
Interested in a private, managed cloud instance? That can be arranged.
|
β‘ 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:
Overview
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: Now uses Google Desktop OAuth clients - no redirect URIs or port configuration needed!
Features
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 |
Quick Start
Set credentials β pick a launch command β connect your client
# 1. Credentials
export GOOGLE_OAUTH_CLIENT_ID="..."
export GOOGLE_OAUTH_CLIENT_SECRET="..."
# 2. Launch β pick a tier
uvx workspace-mcp --tool-tier core # essential tools
uvx workspace-mcp --tool-tier extended # core + management ops
uvx workspace-mcp --tool-tier complete # everything
# Or cherry-pick services
uv run main.py --tools gmail drive calendar
Credential setup β Β· All launch options β Β· Tier details β
Environment Variable Reference| Variable | Purpose | |
|---|---|---|
| π Authentication | ||
GOOGLE_OAUTH_CLIENT_ID |
required | OAuth client ID from Google Cloud |
GOOGLE_OAUTH_CLIENT_SECRET |
required | OAuth client secret |
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 storage 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 |
|
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 β 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 | |
| π 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.
One-Click Claude Desktop Install
.dxtbundles server, deps & manifest β download β double-click β done. No terminal, no JSON editing.
- Download the latest
google_workspace_mcp.dxtfrom Releases - Install β double-click the file, Claude Desktop prompts to install
- Configure β Settings β Extensions β Google Workspace MCP, paste your OAuth credentials
- Use it β start a new Claude chat and call any Google Workspace tool
Prerequisites
Python 3.10+ Β· uv/uvx Β· Google Cloud Project with OAuth 2.0 credentials
Configuration
Google Cloud SetupCreate Project β Open Console β β Create new project
Create OAuth Credentials β APIs & Services β Credentials β Create Credentials β OAuth Client ID
- Choose Desktop Application (no redirect URIs needed!)
- Download and note your Client ID & Client Secret
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"
Full OAuth documentation β Β· Credential setup details β
Google Custom Search Setup
β Custom Search Configuration β Enable web search capabilities|
1. Create Search Engine
|
2. Get API Key
|
3. Set Variables
Configure in environment |
|
β‘ Quick Setup Guide β Step-by-step instructions
Complete Setup Process:
|
Start the Server
βΆ Launch Commands β Choose your startup modeπ 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 |
|
β 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: |
CLI
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.
Tool Tiers
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 |
Usage Examples
# 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
π Credential Configuration
π OAuth Credentials Setup β Essential for all installations|
π Environment Variables
Best for production |
π File-based
Traditional method |
β‘ .env File
Best for development |
|
π Credential Loading Details β Understanding priority & best practices
Loading Priority
Why Environment Variables?
|
π§° Available Tools
Note: All tools support automatic authentication via
@require_google_service()decorators with 30-minute service caching.
π
Google Calendar calendar_tools.py
| 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 |
π Google Drive drive_tools.py
| Tool | Tier | Description |
|---|---|---|
search_drive_files |
Core | Search files with query syntax |
get_drive_file_content |
Core | Read file content (Office formats) |
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 |
π§ Gmail gmail_tools.py
| 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.
π₯ Downloaded Attachment Storage β Where downloaded files are savedWhen 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.
π Google Docs docs_tools.py
| 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 |
π Google Sheets sheets_tools.py
| 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 |
create_sheet |
Complete | Add sheets to existing files |
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 |
πΌοΈ Google Slides slides_tools.py
| 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 |
π Google Forms forms_tools.py
| 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) |
β Google Tasks tasks_tools.py
| 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 |
π€ Google Contacts contacts_tools.py
| 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 |
π¬ Google Chat chat_tools.py
| 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 |
π Google Custom Search search_tools.py
| Tool | Tier | Description |
|---|---|---|
search_custom |
Core | Perform web searches (supports site restrictions via sites parameter) |
get_search_engine_info |
Complete | Retrieve search engine metadata |
β‘ Google Apps Script apps_script_tools.py
| 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
Connect to Claude Desktop
The server supports two transport modes:
Stdio Mode (Legacy - For Clients with Incomplete MCP Support)
β οΈ 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)
π Claude Desktop JSON Config β Click for manual setup instructionsOpen Claude Desktop Settings β Developer β Edit Config
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
- macOS:
Add 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"
}
}
}
}
Connect to LM Studio
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",
}
}
}
}
2. Advanced / Cross-Platform Installation
If youβre developing, deploying to servers, or using another MCP-capable client, keep reading.
Instant CLI (uvx)
β‘ Quick Start with uvx β No installation required!# 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.
Local Development Setup
π οΈ Developer Workflow β Install deps, lint, and test# 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 testinstalls only the testing stack if you need a slimmer environment.uv run main.py --transport streamable-httplaunches the server with your checked-out code for manual verification.- Ruff is part of the
devgroup because pre-push hooks callruff checkautomaticallyβrun it locally before committing to avoid hook failures.
OAuth 2.1 Support (Multi-User Bearer Token Authentication)
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 GOOGLE_OAUTH_CLIENT_SECRET credentials - no additional configuration needed!
When to use OAuth 2.1:
- Multiple users accessing the same MCP server instance
- Need for bearer token authentication instead of passing user emails
- Building web applications or APIs on top of the MCP server
- Production environments requiring secure session management
- Browser-based clients requiring CORS support
β οΈ Important: OAuth 2.1 and Single-User Mode are mutually exclusive
OAuth 2.1 mode (MCP_ENABLE_OAUTH21=true) cannot be used together with the --single-user flag:
- Single-user mode: For legacy clients that pass user emails in tool calls
- OAuth 2.1 mode: For modern multi-user scenarios with bearer token authentication
Choose one authentication method - using both 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/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.
Stateless Mode (Container-Friendly)
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:
- No file system writes: Credentials are never written to disk
- No debug logs: File-based logging is completely disabled
- Memory-only sessions: All tokens stored in memory via OAuth 2.1 session store
- Container-ready: Perfect for Docker, Kubernetes, and serverless deployments
- Token per request: Each request must include a valid Bearer token
Requirements:
- Must be used with
MCP_ENABLE_OAUTH21=true - Incompatible with single-user mode
- Clients must handle OAuth flow and send valid tokens with each request
This mode is ideal for:
- Cloud deployments where persistent storage is unavailable
- Multi-tenant environments requiring strict isolation
- Containerized applications with read-only filesystems
- Serverless functions and ephemeral compute environments
MCP Inspector: No additional configuration needed with desktop OAuth client.
Claude Code: No additional configuration needed with desktop OAuth client.
OAuth Proxy Storage Backends
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
π Valkey/Redis Configuration OptionsDisk 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.
External OAuth 2.1 Provider Mode
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:
- Protocol-level auth enabled: All MCP requests (including
initializeandtools/list) require a valid Bearer token, following the standard OAuth 2.1 flow. Unauthenticated requests receive a401with resource metadata pointing to Google's authorization server. - External OAuth flow: Your external system handles the OAuth flow and obtains Google access tokens (
ya29.*) - Token validation: Server validates bearer tokens by calling Google's userinfo API
- Multi-user support: Each request is authenticated independently based on its bearer token
- Resource metadata discovery: The server serves
/.well-known/oauth-protected-resource(RFC 9728) advertising Google as the authorization server and the required scopes
Key Features:
- No local OAuth flow: Server does not provide
/authorize,/token, or/registerendpoints β only resource metadata - Bearer token only: All authentication via
Authorization: Bearer <token>headers - Stateless by design: Works seamlessly with
WORKSPACE_MCP_STATELESS_MODE=true - External identity providers: Integrate with your existing authentication infrastructure
Requirements:
- Must be used with
MCP_ENABLE_OAUTH21=true - OAuth credentials still required for token validation (
GOOGLE_OAUTH_CLIENT_ID,GOOGLE_OAUTH_CLIENT_SECRET) - External system must obtain valid Google OAuth access tokens (ya29.*)
- Each tool call request must include valid bearer token
Use Cases:
- Integrating with existing authentication systems
- Custom OAuth flows managed by your application
- API gateways that handle authentication upstream
- Multi-tenant SaaS applications with centralized auth
- Mobile or web apps with their own OAuth implementation
VS Code MCP Client Support
π VS Code Configuration β Setup for VS Code MCP extensionβ 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.
Claude Code MCP Client Support
π Claude Code Configuration β Setup for Claude Code MCP supportβ 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
Reverse Proxy Setup
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:
- Use
WORKSPACE_EXTERNAL_URLwhen all OAuth endpoints should use the external URL (recommended for reverse proxy setups) - Use
GOOGLE_OAUTH_REDIRECT_URIwhen you only need to override the callback URL - The redirect URI must exactly match what's configured in your Google Cloud Console
- Your reverse proxy must forward OAuth-related requests (
/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.
Development Installation
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):
π§ Developer Setup JSON β For contributors & customization{
"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"
}
}
}
}
HTTP Mode (For debugging or web interfaces)
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.
First-Time Authentication
The server uses Google Desktop OAuth for simplified authentication:
- No redirect URIs needed: Desktop OAuth clients handle authentication without complex callback URLs
- Automatic flow: The server manages the entire OAuth process transparently
- Transport-agnostic: Works seamlessly in both stdio and HTTP modes
When calling a tool:
- Server returns authorization URL
- Open URL in browser and authorize
- Google provides an authorization code
- Paste the code when prompted (or it's handled automatically)
- Server completes authentication and retries your request
β Development
Project Structure
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
Adding New Tools
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
Architecture Highlights
- Service Caching: 30-minute TTL reduces authentication overhead
- Scope Management: Centralized in
SCOPE_GROUPSfor easy maintenance - Error Handling: Native exceptions instead of manual error construction
- Multi-Service Support:
@require_multiple_services()for complex tools
Credential Store System
The server includes an abstract credential store API and a default backend for managing Google OAuth
credentials with support for multiple storage backends:
Features:
- Abstract Interface:
CredentialStorebase class defines standard operations (get, store, delete, list users) - Local File Storage:
LocalDirectoryCredentialStoreimplementation stores credentials as JSON files - Configurable Storage: Environment variable
GOOGLE_MCP_CREDENTIALS_DIRsets storage location - Multi-User Support: Store and manage credentials for multiple Google accounts
- Automatic Directory Creation: Storage directory is created automatically if it doesn't exist
Configuration:
# Optional: Set custom credentials directory
export GOOGLE_MCP_CREDENTIALS_DIR="/path/to/credentials"
# Default locations (if GOOGLE_MCP_CREDENTIALS_DIR not set):
# - ~/.google_workspace_mcp/credentials (if home directory accessible)
# - ./.credentials (fallback)
Usage Example:
from auth.credential_store import get_credential_store
# 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
users = store.list_users()
The credential store automatically handles credential serialization, expiry parsing, and provides error handling for storage operations.
β Security
- Prompt Injection: This MCP server has the capability to retrieve your email, calendar events and drive files. Those emails, events and files could potentially contain prompt injections - i.e. hidden white text that tells it to forward your emails to a different address. You should exercise caution and in general, only connect trusted data to an LLM!
- Credentials: Never commit
.env,client_secret.jsonor the.credentials/directory to source control! - OAuth Callback: Uses
http://localhost:8000/oauth2callbackfor development (requiresOAUTHLIB_INSECURE_TRANSPORT=1) - Transport-Aware Callbacks: Stdio mode starts a minimal HTTP server only for OAuth, ensuring callbacks work in all modes
- Production: Use HTTPS & OAuth 2.1 and configure accordingly
- Scope Minimization: Tools request only necessary permissions
- Local File Access Control: Tools that read local files (e.g., attachments,
file://uploads) are restricted to the user's home directory by default. Override this with theALLOWED_FILE_DIRSenvironment variable:
Regardless of the allowlist, access to sensitive paths (# Colon-separated list of directories (semicolon on Windows) from which local file reads are permitted export ALLOWED_FILE_DIRS="/home/user/documents:/data/shared".env,.ssh/,.aws/,/etc/shadow, credential files, etc.) is always blocked.
β‘ License
MIT License - see LICENSE file for details.
Reviews (0)
Sign in to leave a review.
Leave a reviewNo results found