License: MIT Python 3.10+ PyPI PyPI Downloads Website
Full natural language control over Google Calendar, Drive, Gmail, Docs, Sheets, Slides, Forms, Tasks, and Chat through all MCP clients, AI assistants and developer tools.
The most feature-complete Google Workspace MCP server, now with Remote OAuth2.1 multi-user support and 1-click Claude installation.
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 cloud instance? That can be arranged.
See it in action:
google_workspace_mcp.mp4
βγ γγγΎγΌγ But why?
This README was written with AI assistance, and here's why that matters
As a solo dev building open source tools, comprehensive documentation often wouldn't happen without AI help. Using agentic dev tools like Roo & Claude Code that understand the entire codebase, AI doesn't just regurgitate generic content - it extracts real implementation details and creates accurate, specific documentation.
In this case, Sonnet 4 took a pass & a human (me) verified them 8/16/25.
A production-ready 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.
Simplified Setup: Now uses Google Desktop OAuth clients - no redirect URIs or port configuration needed!
@ Gmail β’ β‘ Drive β’ β§ Calendar β‘ Docs
- Complete Gmail management, end to end coverage
- Full calendar management with advanced features
- File operations with Office format support
- Document creation, editing & comments
- Deep, exhaustive support for fine grained editing
β‘ Forms β’ @ Chat β’ β‘ Sheets β’ β‘ Slides
- Form creation, publish settings & response management
- Space management & messaging capabilities
- Spreadsheet operations with flexible cell management
- Presentation creation, updates & content manipulation
β Authentication & Security
- Advanced OAuth 2.0 & OAuth 2.1 support
- Automatic token refresh & session management
- Transport-aware callback handling
- Multi-user bearer token authentication
- Innovative CORS proxy architecture
β Tasks β’ βγ γγγΎγΌγ Custom Search β’ β» Transport Support
- Full support for all MCP Transports
- OpenAPI compatibility via
mcpo
- Task & task list management with hierarchy
- Programmable Search Engine (PSE) integration
β‘ Quick Reference Card β Essential commands & configs at a glance
β Credentials
export GOOGLE_OAUTH_CLIENT_ID="..." export GOOGLE_OAUTH_CLIENT_SECRET="..."
βΆ Launch Commands
uvx workspace-mcp --tool-tier core uv run main.py --tools gmail drive
β Tool Tiers
- βγγγΎγ
core
- Essential tools - β
extended
- Core + extras - βγγγΎγ
complete
- Everything Details β
- Download: Grab the latest
google_workspace_mcp.dxt
from the "Releases" page - Install: Double-click the file β Claude Desktop opens and prompts you to Install
- Configure: In Claude Desktop β Settings β Extensions β Google Workspace MCP, paste your Google OAuth credentials
- Use it: Start a new Claude chat and call any Google Workspace tool
Why DXT?
Desktop Extensions (
.dxt
) bundle the server, dependencies, and manifest so users go from download β working MCP in one click β no terminal, no JSON editing, no version conflicts.
βγ γγγΎγΌγ Environment Variables β Click to configure in Claude Desktop
Required
|
Optional
|
Claude Desktop stores these securely in the OS keychain; set them once in the extension pane.
install_dxt_workspace.mp4
- Python 3.10+
- uvx (for instant installation) or uv (for development)
- Google Cloud Project with OAuth 2.0 credentials
βγ γγγΎγΌγ Google Cloud Setup β OAuth 2.0 credentials & API enablement
1. Create Project
console.cloud.google.com
β Create new project
β Note project name
2. OAuth Credentials
APIs & Services β Credentials
β Create Credentials
β OAuth Client ID
β Desktop Application
Download & save credentials
3. Enable APIs
APIs & Services β Library
Search & enable:
Calendar, Drive, Gmail,
Docs, Sheets, Slides,
Forms, Tasks, Chat, Search
See quick links below
β‘ OAuth Credential Setup Guide β Step-by-step instructions
Complete Setup Process:
-
Create OAuth 2.0 Credentials - Visit Google Cloud Console
- Create a new project (or use existing)
- Navigate to APIs & Services β Credentials
- Click Create Credentials β OAuth Client ID
- Choose Desktop Application as the application type (no redirect URIs needed!)
- Download credentials and note the Client ID and Client Secret
-
Enable Required APIs - In APIs & Services β Library
- Search for and enable each required API
- Or use the quick links below for one-click enabling
-
Configure Environment - Set your credentials:
export GOOGLE_OAUTH_CLIENT_ID="your-client-id" export GOOGLE_OAUTH_CLIENT_SECRET="your-secret"
β₯ Quick API Enable Links β One-click enable each Google API
You can enable each one by clicking the links below (make sure you're logged into the Google Cloud Console and have the correct project selected):1.1. Credentials: See Credential Configuration for detailed setup options
- Environment Configuration:
βγ γγγΎγΌγ Environment Variables β Configure your runtime environment
βγ γγγΎγΌγ Development Mode
export OAUTHLIB_INSECURE_TRANSPORT=1
Allows HTTP redirect URIs
@ Default User
export USER_GOOGLE_EMAIL=\
your.email@gmail.com
Single-user authentication
βγ γγγΎγΌγ Custom Search
export GOOGLE_PSE_API_KEY=xxx export GOOGLE_PSE_ENGINE_ID=yyy
Optional: Search API setup
- Server Configuration:
βγ γγγΎγΌγ Server Settings β Customize ports, URIs & proxies
βγ γγγΎγΌγ Base Configuration
export WORKSPACE_MCP_BASE_URI= http://localhost export WORKSPACE_MCP_PORT=8000
Server URL & port settings
β» Proxy Support
export MCP_ENABLE_OAUTH21= true
Leverage multi-user OAuth2.1 clients
@ Default Email
export USER_GOOGLE_EMAIL=\
your.email@gmail.com
Skip email in auth flows in single user mode
β‘ Configuration Details β Learn more about each setting
Variable | Description | Default |
---|---|---|
WORKSPACE_MCP_BASE_URI |
Base server URI (no port) | http://localhost |
WORKSPACE_MCP_PORT |
Server listening port | 8000 |
WORKSPACE_EXTERNAL_URL |
External URL for reverse proxy setups | None |
GOOGLE_OAUTH_REDIRECT_URI |
Override OAuth callback URL | Auto-constructed |
USER_GOOGLE_EMAIL |
Default auth email | None |
βγ γγγΎγΌγ Custom Search Configuration β Enable web search capabilities
1. Create Search Engine
programmablesearchengine.google.com
/controlpanel/create
β Configure sites or entire web
β Note your Engine ID (cx)
2. Get API Key
developers.google.com
/custom-search/v1/overview
β Create/select project
β Enable Custom Search API
β Create credentials (API Key)
3. Set Variables
export GOOGLE_PSE_API_KEY=\ "your-api-key" export GOOGLE_PSE_ENGINE_ID=\ "your-engine-id"
Configure in environment
β‘ Quick Setup Guide β Step-by-step instructions
Complete Setup Process:
-
Create Search Engine - Visit the Control Panel
- Choose "Search the entire web" or specify sites
- Copy the Search Engine ID (looks like:
017643444788157684527:6ivsjbpxpqw
)
-
Enable API & Get Key - Visit Google Developers Console
- Enable "Custom Search API" in your project
- Create credentials β API Key
- Restrict key to Custom Search API (recommended)
-
Configure Environment - Add to your shell or
.env
:export GOOGLE_PSE_API_KEY="AIzaSy..." export GOOGLE_PSE_ENGINE_ID="01764344478..."
βΆ Launch Commands β Choose your startup mode
βΆ Quick Start
uv run main.py
Default stdio mode
βγ γγγΎγΌγ HTTP Mode
uv run main.py \ --transport streamable-http
Web interfaces & debugging
@ Single User
uv run main.py \ --single-user
Simplified authentication
βγ γγγΎγΌγ Advanced Options β Tool selection, tiers & Docker
βΆ Selective Tool Loading
# Load specific services only uv run main.py --tools gmail drive calendar uv run main.py --tools sheets docs # Combine with other flags uv run main.py --single-user --tools gmail
β Tool Tiers
uv run main.py --tool-tier core # βγγγΎγ Essential tools only uv run main.py --tool-tier extended # β Core + additional uv run main.py --tool-tier complete # βγγγΎγ All available tools
βγ γγγΎγΌγ Docker Deployment
docker build -t workspace-mcp . docker run -p 8000:8000 -v $(pwd):/app \ workspace-mcp --transport streamable-http # With tool selection via environment variables docker run -e TOOL_TIER=core workspace-mcp docker run -e TOOLS="gmail drive calendar" workspace-mcp
Available Services: gmail
β’ drive
β’ calendar
β’ docs
β’ sheets
β’ forms
β’ tasks
β’ chat
β’ search
The server organizes tools into three progressive tiers for simplified deployment. Choose a tier that matches your usage needs and API quota requirements.
βγγγΎγ Core (--tool-tier core
)
Essential tools for everyday tasks. Perfect for light usage with minimal API quotas. Includes search, read, create, and basic modify operations across all services.
βγγγΎγ Extended (--tool-tier extended
)
Core functionality plus management tools. Adds labels, folders, batch operations, and advanced search. Ideal for regular usage with moderate API needs.
βγγγΎγ Complete (--tool-tier complete
)
Full API access including comments, headers/footers, publishing settings, and administrative functions. For power users needing maximum functionality.
βΆ Start with core
and upgrade as needed
βΆ Tiers are cumulative β each includes all previous
βΆ Mix and match with --tools
for specific services
βΆ Configuration in core/tool_tiers.yaml
βΆ Authentication included in all tiers
# 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
π OAuth Credentials Setup β Essential for all installations
π Environment Variables
export GOOGLE_OAUTH_CLIENT_ID=\ "your-client-id" export GOOGLE_OAUTH_CLIENT_SECRET=\ "your-secret"
Best for production
π File-based
# Download & place in project root client_secret.json # Or specify custom path export GOOGLE_CLIENT_SECRET_PATH=\ /path/to/secret.json
Traditional method
β‘ .env File
cp .env.oauth21 .env
# Edit .env with credentials
Best for development
π Credential Loading Details β Understanding priority & best practices
Loading Priority
- Environment variables (
export VAR=value
) .env
file in project root (warning - if you run viauvx
rather thanuv run
from the repo directory, you are spawning a standalone process not associated with your clone of the repo and it will not find your .env file without specifying it directly)client_secret.json
viaGOOGLE_CLIENT_SECRET_PATH
- Default
client_secret.json
in project root
Why Environment Variables?
- β Docker/K8s ready - Native container support
- β Cloud platforms - Heroku, Railway, Vercel
- β CI/CD pipelines - GitHub Actions, Jenkins
- β No secrets in git - Keep credentials secure
- β Easy rotation - Update without code changes
Note: All tools support automatic authentication via
@require_google_service()
decorators with 30-minute service caching.
π
Google Calendar |
Tool | Tier | Description |
---|---|---|
list_calendars |
Core | List accessible calendars |
get_events |
Core | Retrieve events with time range filtering |
create_event |
Core | Create events with attachments & reminders |
modify_event |
Core | Update existing events |
delete_event |
Extended | Remove 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) |
list_drive_items |
Extended | List folder contents |
create_drive_file |
Core | Create files or fetch from URLs |
π§ 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 |
manage_gmail_label |
Extended | Create/update/delete labels |
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 | Initialize authentication |
π 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 | Modify document text |
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 |
insert_doc_image |
Complete | Insert images from Drive/URLs |
update_doc_headers_footers |
Complete | Modify headers and footers |
batch_update_doc |
Complete | Execute multiple operations |
inspect_doc_structure |
Complete | Analyze document structure |
export_doc_to_pdf |
Extended | Export document to PDF |
create_table_with_data |
Complete | Create data tables |
debug_table_structure |
Complete | Debug table issues |
*_document_comments |
Complete | Read, Reply, Create, Resolve |
π 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 |
create_sheet |
Complete | Add sheets to existing files |
*_sheet_comment |
Complete | Read/create/reply/resolve comments |
πΌοΈ 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 |
*_presentation_comment |
Complete | Read/create/reply/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 |
β Google Tasks tasks_tools.py
Tool | Tier | Description |
---|---|---|
list_tasks |
Core | List tasks with filtering |
get_task |
Core | Retrieve task details |
create_task |
Core | Create tasks with hierarchy |
update_task |
Core | Modify task properties |
delete_task |
Extended | Remove tasks |
move_task |
Complete | Reposition tasks |
clear_completed_tasks |
Complete | Hide completed tasks |
*_task_list |
Complete | List/get/create/update/delete task lists |
π¬ 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 |
π Google Custom Search search_tools.py
Tool | Tier | Description |
---|---|---|
search_custom |
Core | Perform web searches |
get_search_engine_info |
Complete | Retrieve search engine metadata |
search_custom_siterestrict |
Extended | Search within specific domains |
Tool Tier Legend:
- β’ Core: Essential tools for basic functionality β’ Minimal API usage β’ Getting started
- β’ Extended: Core tools + additional features β’ Regular usage β’ Expanded capabilities
- β’ Complete: All available tools including advanced features β’ Power users β’ Full API access
The server supports two transport modes:
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 instructions
-
Open 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" } } } }
If youβre developing, deploying to servers, or using another MCP-capable client, keep reading.
β‘ 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,
.env
file, orclient_secret.json
.
π οΈ 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 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.- Ruff is part of the
dev
group because pre-push hooks callruff 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 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
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.
π How the FastMCP GoogleProvider handles OAuth β Advanced OAuth 2.1 details
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.
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 Inspector: No additional configuration needed with desktop OAuth client.
π VS Code Configuration β Setup for VS Code MCP extension
{ "servers": { "google-workspace": { "url": "http://localhost:8000/mcp/", "type": "http" } } }
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_URL
when all OAuth endpoints should use the external URL (recommended for reverse proxy setups) - Use
GOOGLE_OAUTH_REDIRECT_URI
when 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
π Advanced uvx Commands β More startup options
# 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):
π§ 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" } } } }
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:
- 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
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
- Service Caching: 30-minute TTL reduces authentication overhead
- Scope Management: Centralized in
SCOPE_GROUPS
for easy maintenance - Error Handling: Native exceptions instead of manual error construction
- Multi-Service Support:
@require_multiple_services()
for complex tools
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:
CredentialStore
base class defines standard operations (get, store, delete, list users) - Local File Storage:
LocalDirectoryCredentialStore
implementation stores credentials as JSON files - Configurable Storage: Environment variable
GOOGLE_MCP_CREDENTIALS_DIR
sets 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("user@example.com", credentials) # Retrieve credentials creds = store.get_credential("user@example.com") # 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.
- Credentials: Never commit
.env
,client_secret.json
or the.credentials/
directory to source control! - OAuth Callback: Uses
http://localhost:8000/oauth2callback
for 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
- Network Exposure: Consider authentication when using
mcpo
over networks - Scope Minimization: Tools request only necessary permissions
βγ γγγΎγΌγ Open WebUI Integration β Connect to Open WebUI as tool provider
# Set credentials & launch in one command GOOGLE_OAUTH_CLIENT_ID="your_id" \ GOOGLE_OAUTH_CLIENT_SECRET="your_secret" \ uvx mcpo --port 8000 --api-key "secret" \ -- uvx workspace-mcp
- Create
config.json
:
{ "mcpServers": { "google_workspace": { "type": "streamablehttp", "url": "http://localhost:8000/mcp" } } }
- Start MCPO:
mcpo --port 8001 --config config.json
- Navigate to Settings β Connections β Tools
- Click Add Tool and enter:
- Server URL:
http://localhost:8001/google_workspace
- API Key: Your mcpo
--api-key
(if set)
- Server URL:
- Save - Google Workspace tools are now available!
MIT License - see LICENSE
file for details.
Validations: MCP Badge