The world's most feature-complete Google Workspace MCP server
Connect MCP Clients, AI assistants and developer tools to Google Calendar, Drive, Gmail, Docs, Sheets, Forms, and Chat through the Model Context Protocol
See it in action:
google_workspace_mcp.mp4
A production-ready MCP server that integrates all major Google Workspace services with AI assistants. Built with FastMCP for optimal performance, featuring advanced authentication handling, service caching, and streamlined development patterns.
- π Advanced OAuth 2.0: Secure authentication with automatic token refresh, transport-aware callback handling, session management, and centralized scope management
- π Google Calendar: Full calendar management with event CRUD operations
- π Google Drive: File operations with native Microsoft Office format support (.docx, .xlsx)
- π§ Gmail: Complete email management with search, send, and draft capabilities
- π Google Docs: Document operations including content extraction and creation
- π Google Sheets: Comprehensive spreadsheet management with flexible cell operations
- π Google Forms: Form creation, retrieval, publish settings, and response management
- π¬ Google Chat: Space management and messaging capabilities
- π Multiple Transports: HTTP with SSE fallback, OpenAPI compatibility via
mcpo
- β‘ High Performance: Service caching, thread-safe sessions, FastMCP integration
- π§© Developer Friendly: Minimal boilerplate, automatic service injection, centralized configuration
- Python 3.11+
- uv (recommended) or pip
- Google Cloud Project with OAuth 2.0 credentials
git clone https://github.com/taylorwilsdon/google_workspace_mcp.git
cd google_workspace_mcp
uv run main.py
-
Google Cloud Setup:
- Create OAuth 2.0 credentials (web application) in Google Cloud Console
- Enable APIs: Calendar, Drive, Gmail, Docs, Sheets, Forms, Chat
- Download credentials as
client_secret.json
in project root - Add redirect URI:
http://localhost:8000/oauth2callback
-
Environment:
export OAUTHLIB_INSECURE_TRANSPORT=1 # Development only
-
Server Configuration: The server's base URL and port can be customized using environment variables:
WORKSPACE_MCP_BASE_URI
: Sets the base URI for the server (default: http://localhost). This affects the server_url used for Gemini native function calling and the OAUTH_REDIRECT_URI.WORKSPACE_MCP_PORT
: Sets the port the server listens on (default: 8000). This affects the server_url, port, and OAUTH_REDIRECT_URI.
# Default (stdio mode for MCP clients)
uv run main.py
# HTTP mode (for web interfaces and debugging)
uv run main.py --transport streamable-http
# Single-user mode (simplified authentication)
uv run main.py --single-user
# Selective tool registration (only register specific tools)
uv run main.py --tools gmail drive calendar
uv run main.py --tools sheets docs
uv run main.py --single-user --tools gmail # Can combine with other flags
# Docker
docker build -t google-workspace-mcp .
docker run -p 8000:8000 -v $(pwd):/app google-workspace-mcp --transport streamable-http
Available Tools for --tools
flag: gmail
, drive
, calendar
, docs
, sheets
, forms
, chat
The server supports two transport modes:
Option 1: Auto-install (Recommended)
python install_claude.py
Option 2: Manual Configuration
- Open Claude Desktop Settings β Developer β Edit Config
- This creates/opens the config file at:
- 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": "uv",
"args": ["run", "main.py"],
"cwd": "/path/to/google_workspace_mcp"
}
}
}
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 features transport-aware OAuth callback handling:
- Stdio Mode: Automatically starts a minimal HTTP server on port 8000 for OAuth callbacks
- HTTP Mode: Uses the existing FastAPI server for OAuth callbacks
- Same OAuth Flow: Both modes use
http://localhost:8000/oauth2callback
for consistency
When calling a tool:
- Server returns authorization URL
- Open URL in browser and authorize
- Server handles OAuth callback automatically (on port 8000 in both modes)
- Retry the original request
Note: All tools support automatic authentication via
@require_google_service()
decorators with 30-minute service caching.
π
Google Calendar (calendar_tools.py
)
Tool | Description |
---|---|
list_calendars |
List accessible calendars |
get_events |
Retrieve events with time range filtering |
create_event |
Create events (all-day or timed) |
modify_event |
Update existing events |
delete_event |
Remove events |
π Google Drive (drive_tools.py
)
Tool | Description |
---|---|
search_drive_files |
Search files with query syntax |
get_drive_file_content |
Read file content (supports Office formats) |
list_drive_items |
List folder contents |
create_drive_file |
Create new files |
π§ Gmail (gmail_tools.py
)
Tool | Description |
---|---|
search_gmail_messages |
Search with Gmail operators |
get_gmail_message_content |
Retrieve message content |
send_gmail_message |
Send emails |
draft_gmail_message |
Create drafts |
π Google Docs (docs_tools.py
)
Tool | Description |
---|---|
search_docs |
Find documents by name |
get_doc_content |
Extract document text |
list_docs_in_folder |
List docs in folder |
create_doc |
Create new documents |
π Google Sheets (sheets_tools.py
)
Tool | Description |
---|---|
list_spreadsheets |
List accessible spreadsheets |
get_spreadsheet_info |
Get spreadsheet metadata |
read_sheet_values |
Read cell ranges |
modify_sheet_values |
Write/update/clear cells |
create_spreadsheet |
Create new spreadsheets |
create_sheet |
Add sheets to existing files |
π Google Forms (forms_tools.py
)
Tool | Description |
---|---|
create_form |
Create new forms with title and description |
get_form |
Retrieve form details, questions, and URLs |
set_publish_settings |
Configure form template and authentication settings |
get_form_response |
Get individual form response details |
list_form_responses |
List all responses to a form with pagination |
π¬ Google Chat (chat_tools.py
)
Tool | Description |
---|---|
list_spaces |
List chat spaces/rooms |
get_messages |
Retrieve space messages |
send_message |
Send messages to spaces |
search_messages |
Search across chat history |
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
- Credentials: Never commit
client_secret.json
or.credentials/
directory - 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 for callback URIs and configure accordingly
- Network Exposure: Consider authentication when using
mcpo
over networks - Scope Minimization: Tools request only necessary permissions
To use this server as a tool provider within Open WebUI:
Create a file named config.json
with the following structure to have mcpo
make the streamable HTTP endpoint available as an OpenAPI spec tool:
{
"mcpServers": {
"google_workspace": {
"type": "streamablehttp",
"url": "http://localhost:8000/mcp"
}
}
}
mcpo --port 8001 --config config.json --api-key "your-optional-secret-key"
This command starts the mcpo
proxy, serving your active (assuming port 8000) Google Workspace MCP on port 8001.
- Navigate to your Open WebUI settings
- Go to "Connections" β "Tools"
- Click "Add Tool"
- Enter the Server URL:
http://localhost:8001/google_workspace
(matching the mcpo base URL and server name from config.json) - If you used an
--api-key
with mcpo, enter it as the API Key - Save the configuration
The Google Workspace tools should now be available when interacting with models in Open WebUI.
MIT License - see LICENSE
file for details.