google workspace mcp
Provides authenticated access to Google Workspace APIs with a focus on Gmail operations and planned Calendar support, featuring secure OAuth authentication and multi-account management with detailed error handling.
Provides authenticated access to Google Workspace APIs with a focus on Gmail operations and planned Calendar support, featuring secure OAuth authentication and multi-account management with detailed error handling.
This Model Context Protocol (MCP) server puts you in control of your Google Workspace. Once you connect your account - a simple, secure process that takes just a minute - you're ready to go. Behind the scenes, it keeps your connection safe and active, so you can focus on getting things done instead of managing logins and permissions.
Take command of your Gmail inbox in ways you never thought possible. Want that proposal from last quarter? Found in seconds. Drowning in newsletters? They'll sort themselves into folders automatically. Need to track responses to an important thread? Labels and filters do the work for you. From drafting the perfect email to managing conversations with your team, everything just clicks into place. With streamlined attachment handling, you can easily find and manage email attachments while the system takes care of all the complex metadata behind the scenes.
Your calendar becomes a trusted ally in the daily juggle. No more double-booked meetings or timezone confusion. Planning a team sync? It spots the perfect time slots. Running a recurring workshop? Set it up once, and you're done. Even when plans change, finding new times that work for everyone is quick and painless. The days of endless "when are you free?" emails are over.
Turn Google Drive from a file dump into your digital command center. Every document finds its place, every folder tells a story. Share files with exactly the right people - no more "who can edit this?" confusion. Looking for that presentation from last week's meeting? Search not just names, but what's inside your files. Whether you're organizing a small project or managing a mountain of documents, everything stays right where you need it.
Note: For AI assistants like Cline, see llms-install.md for specialized installation guidance.
Create Google Cloud Project:
# Go to Google Cloud Console
https://console.cloud.google.com
→ Create Project
→ Enable Gmail API and Calendar API
→ Configure OAuth consent screen (External)
→ Create OAuth Desktop Client ID and Secret
Add to Cline settings (e.g., ~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
):
{
"mcpServers": {
"google-workspace-mcp": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"-v", "/home/aaron/.mcp/google-workspace-mcp:/app/config",
"-v", "/home/aaron/Documents/workspace-mcp-files:/app/workspace",
"-e", "GOOGLE_CLIENT_ID",
"-e", "GOOGLE_CLIENT_SECRET",
"-e", "LOG_MODE=strict",
"ghcr.io/aaronsb/google-workspace-mcp:latest"
],
"env": {
"GOOGLE_CLIENT_ID": "123456789012-abcdef3gh1jklmn2pqrs4uvw5xyz6789.apps.googleusercontent.com",
"GOOGLE_CLIENT_SECRET": "GOCSPX-abcdefghijklmnopqrstuvwxyz1234"
},
"autoApprove": [],
"disabled": false
}
}
}
Logging modes:
- normal
(default): Uses appropriate console methods for each log level
- strict
: Routes all non-JSON-RPC messages to stderr (recommended for Claude desktop)
Restart Cline/Claude
Just ask the AI to "add my Google account" - it will guide you through the authentication process conversationally.
See detailed setup guide for more information.
Before using this MCP server, you must set up your own Google Cloud Project with access to Google Workspace APIs:
The MCP server requires:
1. Your Google OAuth Client ID and Secret from the steps above
2. Local directory path for storing configuration (recommended: ~/.mcp/google-workspace-mcp
)
Note: This server uses out-of-band (OOB) authentication flow, which means you'll need to manually copy-paste authorization codes during the initial setup of each account.
Add the following configuration to your Cline MCP settings:
{
"mcpServers": {
"google-workspace-mcp": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"-v", "/home/aaron/.mcp/google-workspace-mcp:/app/config",
"-e", "GOOGLE_CLIENT_ID",
"-e", "GOOGLE_CLIENT_SECRET",
"-e", "LOG_MODE=strict",
"ghcr.io/aaronsb/google-workspace-mcp:latest"
],
"env": {
"GOOGLE_CLIENT_ID": "123456789012-abcdef3gh1jklmn2pqrs4uvw5xyz6789.apps.googleusercontent.com",
"GOOGLE_CLIENT_SECRET": "GOCSPX-abcdefghijklmnopqrstuvwxyz1234"
},
"autoApprove": [],
"disabled": false
}
}
}
The server automatically manages files in a structured way:
~/Documents/workspace-mcp-files/
├── [[email protected]]/
│ ├── downloads/ # Files downloaded from Drive
│ └── uploads/ # Files staged for upload
├── [[email protected]]/
│ ├── downloads/
│ └── uploads/
└── shared/
└── temp/ # Temporary files (cleaned up automatically)
The WorkspaceManager creates and maintains this structure automatically: - Creates directories as needed when files are downloaded/uploaded - Organizes files by user email - Handles temporary file cleanup - Maintains proper permissions
You can customize the workspace location by setting the WORKSPACE_BASE_PATH
environment variable.
Important: The server requires an
accounts.json
file in the mounted config directory. For first-time setup, copyaccounts.example.json
toaccounts.json
in your config directory before starting the container.
You can run the container directly:
docker run -i --rm
-v ~/.mcp/google-workspace-mcp:/app/config
-v ~/Documents/workspace-mcp-files:/app/workspace
-e GOOGLE_CLIENT_ID=123456789012-abcdef3gh1jklmn2pqrs4uvw5xyz6789.apps.googleusercontent.com
-e GOOGLE_CLIENT_SECRET=GOCSPX-abcdefghijklmnopqrstuvwxyz1234
-e LOG_MODE=strict
ghcr.io/aaronsb/google-workspace-mcp:latest
The server will automatically: - Create and manage all necessary configuration files - Handle secure storage of credentials and tokens - Maintain proper file permissions
For a fast, CI-like local build and Docker image creation, use the provided script:
# Run the local build pipeline (installs, lints, tests, builds, and creates Docker image)
./scripts/build-local.sh
google-workspace-mcp:local
.--verbose
:
./scripts/build-local.sh --verbose
./scripts/build-local.sh --tag my-custom-tag
/tmp/google-workspace-mcp/
for review.The build script uses Dockerfile.local
which is optimized for local development without platform-specific settings or BuildKit features. This ensures compatibility across different development environments.
You can also build and run the container manually:
# Build the image using the standard Dockerfile
docker build -t google-workspace-mcp:local .
# Or build using the local development Dockerfile (recommended for local development)
docker build -t google-workspace-mcp:local -f Dockerfile.local .
# Run with required environment variables
docker run -i --rm
-v ~/.mcp/google-workspace-mcp:/app/config
-v ~/Documents/workspace-mcp-files:/app/workspace
-e GOOGLE_CLIENT_ID=123456789012-abcdef3gh1jklmn2pqrs4uvw5xyz6789.apps.googleusercontent.com
-e GOOGLE_CLIENT_SECRET=GOCSPX-abcdefghijklmnopqrstuvwxyz1234
-e LOG_MODE=strict
google-workspace-mcp:local
list_workspace_accounts
(aliases: list_accounts, get_accounts, show_accounts)Handles multiple account selection
authenticate_workspace_account
(aliases: auth_account, add_account, connect_account)
Manages token refresh automatically
remove_workspace_account
(aliases: delete_account, disconnect_account, remove_account)
search_workspace_emails
(aliases: search_emails, find_emails, query_emails)Common search patterns for:
send_workspace_email
(aliases: send_email, send_mail, create_email)
get_workspace_gmail_settings
(aliases: get_gmail_settings, gmail_settings, get_mail_settings)manage_workspace_draft
(aliases: manage_draft, draft_operation, handle_draft)manage_workspace_label
(aliases: manage_label, label_operation, handle_label)Visibility settings
manage_workspace_label_assignment
(aliases: assign_label, modify_message_labels, change_message_labels)
System label updates
manage_workspace_label_filter
(aliases: manage_filter, handle_filter, filter_operation)
list_workspace_calendar_events
(aliases: list_events, get_events, show_events)Customizable result limits
get_workspace_calendar_event
(aliases: get_event, view_event, show_event)
Event settings
manage_workspace_calendar_event
(aliases: manage_event, update_event, respond_to_event)
Time zone handling
create_workspace_calendar_event
(aliases: create_event, new_event, schedule_event)
Support for:
delete_workspace_calendar_event
(aliases: delete_event, remove_event, cancel_event)
list_drive_files
(aliases: list_files, get_files, show_files)Field selection
search_drive_files
(aliases: search_files, find_files, query_files)
Advanced query options
upload_drive_file
(aliases: upload_file, create_file, add_file)
Support for various file types
download_drive_file
(aliases: download_file, get_file_content, fetch_file)
Automatic MIME type handling
delete_drive_file
(aliases: delete_file, remove_file, trash_file)
create_drive_folder
(aliases: create_folder, new_folder, add_folder)update_drive_permissions
(aliases: share_file, update_sharing, modify_permissions)See API Documentation for detailed usage.
Mock external dependencies (OAuth, file system) with simple implementations
Test Organization
Reset mocks and modules between tests
Mock Management
Verify both function calls and results
File System Testing
Verify file operations without implementation details
Token Handling
# Run all tests
npm test
# Run specific test file
npm test path/to/test.ts
# Run tests with coverage
npm test -- --coverage
# CI builds run all tests with coverage reporting
npm run test:ci
Handle token refresh properly
Error Handling
Implement proper retries
Configuration & Security
Use proper file permissions for config directory
Local Development Setup
Solution: Configure the OAuth credentials in your MCP settings file (see docs/API.md for details)
Authentication Errors
Solution:
Token Issues
remove_workspace_account
and re-authenticateCheck that your Google Cloud project has the necessary API scopes enabled
Directory Structure
For additional help, consult the Error Handling documentation.
MIT License - See LICENSE file for details