gworkspace-mcp
Search, read, send, label, delete emails and download attachments.
Create, list, update, and delete events with attendees and reminders.
Create, read, append, insert, replace, format text, and insert tables in documents.
Search, upload, download, create folders, share, and delete files.
Create, read, write, manage sheets, and apply formatting.
Full task and tasklist management including subtasks.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@gworkspace-mcpsearch my email for invoices from last month"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
š gworkspace-mcp
A production-ready Model Context Protocol (MCP) server that gives AI assistants full, authenticated access to the entire Google Workspace ecosystem.
š Overview
gworkspace-mcp is a Model Context Protocol (MCP) server built with Python that acts as a secure, structured bridge between AI assistants (such as Claude, Cursor, or any MCP-compatible client) and the full suite of Google Workspace services.
Instead of writing one-off Google API scripts, this server exposes all Google Workspace functionality as named, type-safe MCP tools ā each with clear docstrings, parameter descriptions, and async support. AI agents can call these tools in natural conversation to read emails, manage Drive files, schedule calendar events, and more, all authenticated against a real Google account.
The server handles the entire OAuth 2.0 lifecycle automatically: first-time browser-based authorization, secure token persistence in PostgreSQL, and silent token refresh using stored refresh tokens ā so users never need to re-authenticate.
Related MCP server: google-mcp-server
⨠Features
Feature | Description |
š§ Gmail | Search, read, send, label, delete emails and download attachments |
š Google Drive | Search, upload, download, create folders, share, and delete files |
š Google Calendar | Create, list, update, and delete events with attendees and reminders |
ā Google Tasks | Full task and tasklist management including subtasks |
š Google Docs | Create, read, append, insert, replace, format text, and insert tables in documents |
š OAuth 2.0 | Automated first-time browser login with persistent token storage |
š Token Refresh | Automatic silent refresh of expired access tokens |
šļø PostgreSQL Storage | Per-user token persistence using SQLAlchemy ORM |
ā” Async Architecture | All MCP tools are fully |
šļø Architecture
The project follows a clean, layered architecture that separates concerns across four distinct layers:
gworkspace-mcp/
ā
āāā server.py # Entry point ā initializes FastMCP, registers all tools
āāā main.py # Minimal demo entry point
āāā pyproject.toml # Project metadata and dependency declarations
ā
āāā auth/ # Layer 1: Authentication
ā āāā google_auth.py # OAuth 2.0 flow (first-time login + credential retrieval)
ā āāā token_manager.py # CRUD operations on the token store (get/save/update/delete)
ā
āāā db/ # Layer 2: Persistence
ā āāā database.py # SQLAlchemy engine, session factory, and Base class
ā āāā models.py # ORM model: Tokens table (email, access_token, refresh_token, expiry)
ā
āāā services/ # Layer 3: Business Logic
ā āāā gmail_service.py # Google Gmail API calls (search, read, send, label, delete)
ā āāā drive_service.py # Google Drive API calls (search, upload, download, share, delete)
ā āāā calendar_service.py # Google Calendar API calls (create, list, update, delete)
ā āāā tasks_service.py # Google Tasks API calls (tasks, subtasks, tasklists)
ā āāā docs_service.py # Google Docs API calls (create, read, append, formatting)
ā āāā sheets_service.py # Google Sheets API calls (create, read, write, sheets, formatting)
ā
āāā tools/ # Layer 4: MCP Tool Definitions
ā āāā gmail.py # 7 MCP tools wrapping gmail_service
ā āāā drive.py # 6 MCP tools wrapping drive_service
ā āāā calendar.py # 4 MCP tools wrapping calendar_service
ā āāā tasks.py # 8 MCP tools wrapping tasks_service
ā āāā docs.py # 8 MCP tools wrapping docs_service
ā āāā sheets.py # 10 MCP tools wrapping sheets_service
ā
āāā config/ # Configuration (not committed to source control)
ā āāā credentials.json # Google OAuth client ID and secret
ā āāā .env # Environment variables (DATABASE_URL, etc.)
ā
āāā utils/
āāā helpers.py # Shared utility functionsData Flow
AI Client (Claude, Cursor, etc.)
ā
ā MCP Protocol (stdio / SSE)
ā¼
server.py āāāŗ FastMCP instance
ā
ā¼
tools/*.py āāāŗ MCP tool definitions (@mcp.tool decorator)
ā
ā¼
services/*.py āāāŗ Google API business logic
ā (uses authenticated credentials)
ā
āāāāŗ auth/google_auth.py āāāŗ Retrieves or refreshes credentials
ā ā
ā ā¼
ā auth/token_manager.py āāāŗ Reads/writes token from DB
ā ā
ā ā¼
ā db/models.py + db/database.py āāāŗ PostgreSQL
ā
ā¼
Google Workspace APIs (Gmail, Drive, Calendar, Tasks, ...)š Authentication System
One of the most robust parts of this project is the multi-layer OAuth 2.0 authentication system.
How It Works
First-time login: When a user's email is not found in the database,
google_auth.pylaunches a local browser-based OAuth consent flow usingInstalledAppFlow. After the user grants consent, the credentials are automatically saved to PostgreSQL.Subsequent calls: On every API call,
get_google_credentials(email)looks up the stored token. If the access token is still valid, it is returned immediately. If expired, the refresh token is used to silently obtain a new access token viacreds.refresh(Request()), and the updated token is persisted back to the database.Token Storage: Tokens are stored in a
tokenstable with the user'semailas the primary key, along withaccess_token,refresh_token,scopes, andexpiryā all managed through SQLAlchemy.
OAuth Scopes Requested
Scope | Purpose |
| Read, send, search, and organize Gmail (without permanent deletion) |
| Full access to all Google Drive files |
| View and edit all calendar events |
| Create, update, and delete Google Tasks |
| Full access to Google Sheets |
| Full access to Google Docs |
š ļø MCP Tools Reference
š§ Gmail Tools
Tool | Description |
| Search Gmail using any query string (e.g. |
| Read full email content by message ID ā returns body, sender, attachments |
| Download a specific email attachment as base64 by attachment ID |
| Create a new custom label for organizing emails |
| Add or remove labels (including |
| Delete emails by |
| Compose and send an email with optional file attachment |
š Google Drive Tools
Tool | Description |
| Search Drive files/folders by name, MIME type, or any Drive query |
| Upload a single file or recursively upload an entire folder |
| Create a new Drive folder with optional parent folder |
| Download a Drive file to a local path |
| Share a file with a user, group, domain, or make it public with role control |
| Move a file to trash or permanently delete it |
š Google Calendar Tools
Tool | Description |
| Create an event with title, time, location, guests, and reminders |
| List events within a date range, up to a configurable max |
| Update any field of an existing event |
| Delete an event by its ID |
ā Google Tasks Tools
Tool | Description |
| Create a new named task list |
| Create a task with title, notes, and due date |
| Create a subtask nested under an existing parent task |
| Update a task's title, notes, due date, or status ( |
| List tasks with filters (completed, hidden, due date, updated date) |
| List all task lists for the authenticated user |
| Permanently delete a task or subtask (cascades to subtasks) |
| Permanently delete an entire task list and all its tasks |
š Google Docs Tools
Tool | Description |
| Create a new blank Google Document with a title |
| Retrieve the full content and metadata of a Google Document by ID |
| Append text at the end of a Google Document |
| Insert text at a specific character index in a Document |
| Find and replace all occurrences of a text string in a Document |
| Delete content between two character index positions |
| Apply formatting (bold, italic, underline, font size, color) to text |
| Insert an empty table with specified rows and columns |
š Getting Started
Prerequisites
Python 3.12+
A PostgreSQL database instance
A Google Cloud Project with the following APIs enabled:
Gmail API
Google Drive API
Google Calendar API
Google Tasks API
Google Docs API
Google Sheets API
An OAuth 2.0 Client ID (Desktop app type) downloaded as
credentials.json
Installation
# Clone the repository
git clone https://github.com/your-username/gworkspace-mcp.git
cd gworkspace-mcp
# Option 1: Using pip (editable install)
pip install -e .
# Option 2: Using uv (recommended)
uv syncConfiguration
1. Place your Google credentials:
config/credentials.json ā your OAuth 2.0 client secret JSON from Google Cloud Console2. Create the environment file:
# config/.env
DATABASE_URL=postgresql://user:password@localhost:5432/gworkspace_mcp3. (First run only) A browser window will open asking you to authorize with your Google account. After authorization, tokens are stored in the database automatically.
Running the Server
python server.pyThe MCP server will start and listen for connections from any MCP-compatible client.
Connecting to an MCP Client
To connect this server to Claude Desktop, add the following to your claude_desktop_config.json:
{
"mcpServers": {
"gworkspace": {
"command": "python",
"args": ["C:/path/to/gworkspace-mcp/server.py"]
}
}
}š§© Tech Stack
Technology | Role |
Python 3.12+ | Core language |
FastMCP 3.4+ | MCP server framework ā tool registration and protocol handling |
Google API Python Client | Official Google Workspace API client library |
google-auth / google-auth-oauthlib | OAuth 2.0 credential management and token refresh |
SQLAlchemy 2.0 | ORM for database models and session management |
PostgreSQL | Persistent storage for OAuth tokens |
psycopg2-binary / asyncpg | PostgreSQL drivers (sync + async) |
python-dotenv | Environment variable loading from |
š Project Status
Component | Status |
Gmail (tools + service) | ā Complete |
Google Drive (tools + service) | ā Complete |
Google Calendar (tools + service) | ā Complete |
Google Tasks (tools + service) | ā Complete |
OAuth 2.0 + Token Management | ā Complete |
PostgreSQL Token Persistence | ā Complete |
Google Docs (tools + service) | ā Complete |
Google Sheets (tools + service) | ā Complete |
Automated Tests | š Planned |
Docker Support | š Planned |
š£ļø Roadmap
Complete Google Docs service (create, read, update documents)
Complete Google Sheets service (read, write, format, rows/columns manipulation)
Add comprehensive
pytesttest suiteAdd Docker + Docker Compose setup for easy deployment
Add multi-user support with user session isolation
Add rate limiting and error retry logic
Publish to PyPI as an installable MCP server package
š¤ Contributing
Contributions are welcome! Please open an issue first to discuss any significant changes. Make sure to:
Follow the existing layered architecture (tools ā services ā auth/db)
Add proper docstrings to all new MCP tool functions
Test with a real Google account before submitting
ā ļø Security Notice
Never commit
config/credentials.jsonorconfig/.envto version control.Both files are listed in
.gitignoreby default.OAuth tokens are stored in the database ā ensure your PostgreSQL instance is secured appropriately.
š License
This project is licensed under the MIT License. See LICENSE for details.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseBqualityDmaintenanceA Model Context Protocol (MCP) server that connects AI agents to Google Workspace (Gmail, Calendar, Drive, Docs, Sheets, and Slides).Last updated302MIT
- Flicense-qualityBmaintenanceAn MCP server that enables AI assistants to read, search, and act on Google Workspace services including Gmail, Drive, Docs, YouTube, and Calendar.Last updated
- Flicense-qualityDmaintenanceAn MCP server that exposes 17 Google Workspace APIs (e.g., Gmail, Drive, Calendar) as auto-generated tools for AI assistants, enabling natural language control of Google services.Last updated
- AlicenseBqualityBmaintenanceA production-ready MCP server that bridges AI agents with Google Workspace (Gmail & Docs) to securely compose emails and edit documents via standardized tools.Last updated3MIT
Related MCP Connectors
Hosted Google Calendar MCP server for AI agents. No self-hosting or Google Cloud setup.
MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yoā¦
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/rkpraveendev/gworkspace-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server