workspace-mcp 1.0.0__tar.gz → 1.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- workspace_mcp-1.0.2/PKG-INFO +422 -0
- {workspace_mcp-1.0.0 → workspace_mcp-1.0.2}/README.md +43 -9
- {workspace_mcp-1.0.0 → workspace_mcp-1.0.2}/auth/service_decorator.py +31 -32
- {workspace_mcp-1.0.0 → workspace_mcp-1.0.2}/core/server.py +3 -10
- {workspace_mcp-1.0.0 → workspace_mcp-1.0.2}/core/utils.py +36 -0
- workspace_mcp-1.0.2/gcalendar/calendar_tools.py +546 -0
- workspace_mcp-1.0.2/gchat/chat_tools.py +227 -0
- workspace_mcp-1.0.2/gdocs/docs_tools.py +216 -0
- {workspace_mcp-1.0.0 → workspace_mcp-1.0.2}/gdrive/drive_tools.py +168 -171
- workspace_mcp-1.0.2/gforms/forms_tools.py +279 -0
- workspace_mcp-1.0.2/gmail/gmail_tools.py +726 -0
- workspace_mcp-1.0.2/gsheets/sheets_tools.py +340 -0
- workspace_mcp-1.0.2/gslides/slides_tools.py +272 -0
- {workspace_mcp-1.0.0 → workspace_mcp-1.0.2}/main.py +31 -25
- workspace_mcp-1.0.2/pyproject.toml +61 -0
- workspace_mcp-1.0.2/workspace_mcp.egg-info/PKG-INFO +422 -0
- {workspace_mcp-1.0.0 → workspace_mcp-1.0.2}/workspace_mcp.egg-info/requires.txt +2 -0
- workspace_mcp-1.0.0/PKG-INFO +0 -29
- workspace_mcp-1.0.0/gcalendar/calendar_tools.py +0 -496
- workspace_mcp-1.0.0/gchat/chat_tools.py +0 -254
- workspace_mcp-1.0.0/gdocs/docs_tools.py +0 -244
- workspace_mcp-1.0.0/gforms/forms_tools.py +0 -318
- workspace_mcp-1.0.0/gmail/gmail_tools.py +0 -807
- workspace_mcp-1.0.0/gsheets/sheets_tools.py +0 -393
- workspace_mcp-1.0.0/gslides/slides_tools.py +0 -316
- workspace_mcp-1.0.0/pyproject.toml +0 -53
- workspace_mcp-1.0.0/workspace_mcp.egg-info/PKG-INFO +0 -29
- {workspace_mcp-1.0.0 → workspace_mcp-1.0.2}/LICENSE +0 -0
- {workspace_mcp-1.0.0 → workspace_mcp-1.0.2}/auth/__init__.py +0 -0
- {workspace_mcp-1.0.0 → workspace_mcp-1.0.2}/auth/google_auth.py +0 -0
- {workspace_mcp-1.0.0 → workspace_mcp-1.0.2}/auth/oauth_callback_server.py +0 -0
- {workspace_mcp-1.0.0 → workspace_mcp-1.0.2}/auth/oauth_responses.py +0 -0
- {workspace_mcp-1.0.0 → workspace_mcp-1.0.2}/auth/scopes.py +0 -0
- {workspace_mcp-1.0.0 → workspace_mcp-1.0.2}/core/__init__.py +0 -0
- {workspace_mcp-1.0.0 → workspace_mcp-1.0.2}/gcalendar/__init__.py +0 -0
- {workspace_mcp-1.0.0 → workspace_mcp-1.0.2}/gchat/__init__.py +0 -0
- {workspace_mcp-1.0.0 → workspace_mcp-1.0.2}/gdocs/__init__.py +0 -0
- {workspace_mcp-1.0.0 → workspace_mcp-1.0.2}/gdrive/__init__.py +0 -0
- {workspace_mcp-1.0.0 → workspace_mcp-1.0.2}/gforms/__init__.py +0 -0
- {workspace_mcp-1.0.0 → workspace_mcp-1.0.2}/gmail/__init__.py +0 -0
- {workspace_mcp-1.0.0 → workspace_mcp-1.0.2}/gsheets/__init__.py +0 -0
- {workspace_mcp-1.0.0 → workspace_mcp-1.0.2}/gslides/__init__.py +0 -0
- {workspace_mcp-1.0.0 → workspace_mcp-1.0.2}/setup.cfg +0 -0
- {workspace_mcp-1.0.0 → workspace_mcp-1.0.2}/workspace_mcp.egg-info/SOURCES.txt +0 -0
- {workspace_mcp-1.0.0 → workspace_mcp-1.0.2}/workspace_mcp.egg-info/dependency_links.txt +0 -0
- {workspace_mcp-1.0.0 → workspace_mcp-1.0.2}/workspace_mcp.egg-info/entry_points.txt +0 -0
- {workspace_mcp-1.0.0 → workspace_mcp-1.0.2}/workspace_mcp.egg-info/top_level.txt +0 -0
@@ -0,0 +1,422 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: workspace-mcp
|
3
|
+
Version: 1.0.2
|
4
|
+
Summary: Comprehensive, highly performant Google Workspace Streamable HTTP & SSE MCP Server for Calendar, Gmail, Docs, Sheets, Slides & Drive
|
5
|
+
Author-email: Taylor Wilsdon <taylor@taylorwilsdon.com>
|
6
|
+
License: MIT
|
7
|
+
Project-URL: Homepage, https://workspacemcp.com
|
8
|
+
Project-URL: Repository, https://github.com/taylorwilsdon/google_workspace_mcp
|
9
|
+
Project-URL: Documentation, https://github.com/taylorwilsdon/google_workspace_mcp#readme
|
10
|
+
Project-URL: Issues, https://github.com/taylorwilsdon/google_workspace_mcp/issues
|
11
|
+
Project-URL: Changelog, https://github.com/taylorwilsdon/google_workspace_mcp/releases
|
12
|
+
Keywords: mcp,google,workspace,llm,ai,claude,model,context,protocol,server
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
14
|
+
Classifier: Environment :: Console
|
15
|
+
Classifier: Intended Audience :: Developers
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
17
|
+
Classifier: Natural Language :: English
|
18
|
+
Classifier: Operating System :: OS Independent
|
19
|
+
Classifier: Programming Language :: Python
|
20
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
23
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
24
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
|
25
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
26
|
+
Classifier: Topic :: Communications :: Chat
|
27
|
+
Classifier: Topic :: Office/Business
|
28
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
29
|
+
Classifier: Typing :: Typed
|
30
|
+
Requires-Python: >=3.11
|
31
|
+
Description-Content-Type: text/markdown
|
32
|
+
License-File: LICENSE
|
33
|
+
Requires-Dist: fastapi>=0.115.12
|
34
|
+
Requires-Dist: fastmcp>=2.3.3
|
35
|
+
Requires-Dist: google-api-python-client>=2.168.0
|
36
|
+
Requires-Dist: google-auth-httplib2>=0.2.0
|
37
|
+
Requires-Dist: google-auth-oauthlib>=1.2.2
|
38
|
+
Requires-Dist: httpx>=0.28.1
|
39
|
+
Requires-Dist: pyjwt>=2.10.1
|
40
|
+
Requires-Dist: tomlkit
|
41
|
+
Dynamic: license-file
|
42
|
+
|
43
|
+
<div align="center">
|
44
|
+
|
45
|
+
# Google Workspace MCP Server <img src="https://github.com/user-attachments/assets/b89524e4-6e6e-49e6-ba77-00d6df0c6e5c" width="80" align="right" />
|
46
|
+
|
47
|
+
[](https://opensource.org/licenses/MIT)
|
48
|
+
[](https://www.python.org/downloads/)
|
49
|
+
[](https://pypi.org/project/workspace-mcp/)
|
50
|
+
[](https://github.com/astral-sh/uv)
|
51
|
+
[](https://workspacemcp.com)
|
52
|
+
[](https://mseep.ai/app/eebbc4a6-0f8c-41b2-ace8-038e5516dba0)
|
53
|
+
|
54
|
+
**This is the single most feature-complete Google Workspace MCP server**
|
55
|
+
|
56
|
+
*Full natural language control over Google Calendar, Drive, Gmail, Docs, Sheets, Slides, Forms, and Chat through all MCP clients, AI assistants and developer tools*
|
57
|
+
|
58
|
+
</div>
|
59
|
+
|
60
|
+
<div align="center">
|
61
|
+
<a href="https://glama.ai/mcp/servers/@taylorwilsdon/google_workspace_mcp">
|
62
|
+
<img width="195" src="https://glama.ai/mcp/servers/@taylorwilsdon/google_workspace_mcp/badge" alt="Google Workspace Server MCP server" align="center"/>
|
63
|
+
</a>
|
64
|
+
<a href="https://www.pulsemcp.com/servers/taylorwilsdon-google-workspace">
|
65
|
+
<img width="456" src="https://github.com/user-attachments/assets/0794ef1a-dc1c-447d-9661-9c704d7acc9d" align="center"/>
|
66
|
+
</a>
|
67
|
+
</div>
|
68
|
+
|
69
|
+
---
|
70
|
+
|
71
|
+
|
72
|
+
**See it in action:**
|
73
|
+
<div align="center">
|
74
|
+
<video width="832" src="https://github.com/user-attachments/assets/a342ebb4-1319-4060-a974-39d202329710"></video>
|
75
|
+
</div>
|
76
|
+
|
77
|
+
---
|
78
|
+
|
79
|
+
|
80
|
+
## 🌐 Overview
|
81
|
+
|
82
|
+
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.
|
83
|
+
|
84
|
+
## ✨ Features
|
85
|
+
|
86
|
+
- **🔐 Advanced OAuth 2.0**: Secure authentication with automatic token refresh, transport-aware callback handling, session management, and centralized scope management
|
87
|
+
- **📅 Google Calendar**: Full calendar management with event CRUD operations
|
88
|
+
- **📁 Google Drive**: File operations with native Microsoft Office format support (.docx, .xlsx)
|
89
|
+
- **📧 Gmail**: Complete email management with search, send, and draft capabilities
|
90
|
+
- **📄 Google Docs**: Document operations including content extraction and creation
|
91
|
+
- **📊 Google Sheets**: Comprehensive spreadsheet management with flexible cell operations
|
92
|
+
- **🖼️ Google Slides**: Presentation management with slide creation, updates, and content manipulation
|
93
|
+
- **📝 Google Forms**: Form creation, retrieval, publish settings, and response management
|
94
|
+
- **💬 Google Chat**: Space management and messaging capabilities
|
95
|
+
- **🔄 Multiple Transports**: HTTP with SSE fallback, OpenAPI compatibility via `mcpo`
|
96
|
+
- **⚡ High Performance**: Service caching, thread-safe sessions, FastMCP integration
|
97
|
+
- **🧩 Developer Friendly**: Minimal boilerplate, automatic service injection, centralized configuration
|
98
|
+
|
99
|
+
---
|
100
|
+
|
101
|
+
## 🚀 Quick Start
|
102
|
+
|
103
|
+
### Simplest Start (uvx - Recommended)
|
104
|
+
|
105
|
+
Run instantly without installation:
|
106
|
+
|
107
|
+
```bash
|
108
|
+
# Start the server with all Google Workspace tools
|
109
|
+
uvx workspace-mcp
|
110
|
+
|
111
|
+
# Start with specific tools only
|
112
|
+
uvx workspace-mcp --tools gmail drive calendar
|
113
|
+
|
114
|
+
# Start in HTTP mode for debugging
|
115
|
+
uvx workspace-mcp --transport streamable-http
|
116
|
+
```
|
117
|
+
|
118
|
+
*Requires Python 3.11+ and [uvx](https://github.com/astral-sh/uv). The package is available on [PyPI](https://pypi.org/project/workspace-mcp).*
|
119
|
+
|
120
|
+
### Development Installation
|
121
|
+
|
122
|
+
For development or customization:
|
123
|
+
|
124
|
+
```bash
|
125
|
+
git clone https://github.com/taylorwilsdon/google_workspace_mcp.git
|
126
|
+
cd google_workspace_mcp
|
127
|
+
uv run main.py
|
128
|
+
```
|
129
|
+
|
130
|
+
### Prerequisites
|
131
|
+
|
132
|
+
- **Python 3.11+**
|
133
|
+
- **[uvx](https://github.com/astral-sh/uv)** (for instant installation) or [uv](https://github.com/astral-sh/uv) (for development)
|
134
|
+
- **Google Cloud Project** with OAuth 2.0 credentials
|
135
|
+
|
136
|
+
### Configuration
|
137
|
+
|
138
|
+
1. **Google Cloud Setup**:
|
139
|
+
- Create OAuth 2.0 credentials (web application) in [Google Cloud Console](https://console.cloud.google.com/)
|
140
|
+
- Enable APIs: Calendar, Drive, Gmail, Docs, Sheets, Slides, Forms, Chat
|
141
|
+
- Download credentials as `client_secret.json` in project root
|
142
|
+
- To use a different location for `client_secret.json`, you can set the `GOOGLE_CLIENT_SECRETS` environment variable with that path
|
143
|
+
- Add redirect URI: `http://localhost:8000/oauth2callback`
|
144
|
+
|
145
|
+
2. **Environment**:
|
146
|
+
```bash
|
147
|
+
export OAUTHLIB_INSECURE_TRANSPORT=1 # Development only
|
148
|
+
```
|
149
|
+
|
150
|
+
3. **Server Configuration**:
|
151
|
+
The server's base URL and port can be customized using environment variables:
|
152
|
+
- `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.
|
153
|
+
- `WORKSPACE_MCP_PORT`: Sets the port the server listens on (default: 8000). This affects the server_url, port, and OAUTH_REDIRECT_URI.
|
154
|
+
|
155
|
+
### Start the Server
|
156
|
+
|
157
|
+
```bash
|
158
|
+
# Default (stdio mode for MCP clients)
|
159
|
+
uv run main.py
|
160
|
+
|
161
|
+
# HTTP mode (for web interfaces and debugging)
|
162
|
+
uv run main.py --transport streamable-http
|
163
|
+
|
164
|
+
# Single-user mode (simplified authentication)
|
165
|
+
uv run main.py --single-user
|
166
|
+
|
167
|
+
# Selective tool registration (only register specific tools)
|
168
|
+
uv run main.py --tools gmail drive calendar
|
169
|
+
uv run main.py --tools sheets docs
|
170
|
+
uv run main.py --single-user --tools gmail # Can combine with other flags
|
171
|
+
|
172
|
+
# Docker
|
173
|
+
docker build -t workspace-mcp .
|
174
|
+
docker run -p 8000:8000 -v $(pwd):/app workspace-mcp --transport streamable-http
|
175
|
+
```
|
176
|
+
|
177
|
+
**Available Tools for `--tools` flag**: `gmail`, `drive`, `calendar`, `docs`, `sheets`, `forms`, `chat`
|
178
|
+
|
179
|
+
### Connect to Claude Desktop
|
180
|
+
|
181
|
+
The server supports two transport modes:
|
182
|
+
|
183
|
+
#### Stdio Mode (Default - Recommended for Claude Desktop)
|
184
|
+
**Option 1: Auto-install (Recommended)**
|
185
|
+
```bash
|
186
|
+
python install_claude.py
|
187
|
+
```
|
188
|
+
|
189
|
+
**Option 2: Manual Configuration**
|
190
|
+
1. Open Claude Desktop Settings → Developer → Edit Config
|
191
|
+
2. This creates/opens the config file at:
|
192
|
+
- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
193
|
+
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
194
|
+
3. Add the server configuration:
|
195
|
+
|
196
|
+
```json
|
197
|
+
{
|
198
|
+
"mcpServers": {
|
199
|
+
"google_workspace": {
|
200
|
+
"command": "uvx",
|
201
|
+
"args": ["workspace-mcp"]
|
202
|
+
}
|
203
|
+
}
|
204
|
+
}
|
205
|
+
```
|
206
|
+
|
207
|
+
**Alternative (Development Installation)**:
|
208
|
+
```json
|
209
|
+
{
|
210
|
+
"mcpServers": {
|
211
|
+
"google_workspace": {
|
212
|
+
"command": "uv",
|
213
|
+
"args": ["run", "main.py"],
|
214
|
+
"cwd": "/path/to/google_workspace_mcp"
|
215
|
+
}
|
216
|
+
}
|
217
|
+
}
|
218
|
+
```
|
219
|
+
|
220
|
+
#### HTTP Mode (For debugging or web interfaces)
|
221
|
+
If you need to use HTTP mode with Claude Desktop:
|
222
|
+
|
223
|
+
```json
|
224
|
+
{
|
225
|
+
"mcpServers": {
|
226
|
+
"google_workspace": {
|
227
|
+
"command": "npx",
|
228
|
+
"args": ["mcp-remote", "http://localhost:8000/mcp"]
|
229
|
+
}
|
230
|
+
}
|
231
|
+
}
|
232
|
+
```
|
233
|
+
|
234
|
+
*Note: Make sure to start the server with `--transport streamable-http` when using HTTP mode.*
|
235
|
+
|
236
|
+
### First-Time Authentication
|
237
|
+
|
238
|
+
The server features **transport-aware OAuth callback handling**:
|
239
|
+
|
240
|
+
- **Stdio Mode**: Automatically starts a minimal HTTP server on port 8000 for OAuth callbacks
|
241
|
+
- **HTTP Mode**: Uses the existing FastAPI server for OAuth callbacks
|
242
|
+
- **Same OAuth Flow**: Both modes use `http://localhost:8000/oauth2callback` for consistency
|
243
|
+
|
244
|
+
When calling a tool:
|
245
|
+
1. Server returns authorization URL
|
246
|
+
2. Open URL in browser and authorize
|
247
|
+
3. Server handles OAuth callback automatically (on port 8000 in both modes)
|
248
|
+
4. Retry the original request
|
249
|
+
|
250
|
+
---
|
251
|
+
|
252
|
+
## 🧰 Available Tools
|
253
|
+
|
254
|
+
> **Note**: All tools support automatic authentication via `@require_google_service()` decorators with 30-minute service caching.
|
255
|
+
|
256
|
+
### 📅 Google Calendar ([`calendar_tools.py`](gcalendar/calendar_tools.py))
|
257
|
+
|
258
|
+
| Tool | Description |
|
259
|
+
|------|-------------|
|
260
|
+
| `list_calendars` | List accessible calendars |
|
261
|
+
| `get_events` | Retrieve events with time range filtering |
|
262
|
+
| `create_event` | Create events (all-day or timed) |
|
263
|
+
| `modify_event` | Update existing events |
|
264
|
+
| `delete_event` | Remove events |
|
265
|
+
|
266
|
+
### 📁 Google Drive ([`drive_tools.py`](gdrive/drive_tools.py))
|
267
|
+
|
268
|
+
| Tool | Description |
|
269
|
+
|------|-------------|
|
270
|
+
| `search_drive_files` | Search files with query syntax |
|
271
|
+
| `get_drive_file_content` | Read file content (supports Office formats) |
|
272
|
+
| `list_drive_items` | List folder contents |
|
273
|
+
| `create_drive_file` | Create new files |
|
274
|
+
|
275
|
+
### 📧 Gmail ([`gmail_tools.py`](gmail/gmail_tools.py))
|
276
|
+
|
277
|
+
| Tool | Description |
|
278
|
+
|------|-------------|
|
279
|
+
| `search_gmail_messages` | Search with Gmail operators |
|
280
|
+
| `get_gmail_message_content` | Retrieve message content |
|
281
|
+
| `send_gmail_message` | Send emails |
|
282
|
+
| `draft_gmail_message` | Create drafts |
|
283
|
+
|
284
|
+
### 📝 Google Docs ([`docs_tools.py`](gdocs/docs_tools.py))
|
285
|
+
|
286
|
+
| Tool | Description |
|
287
|
+
|------|-------------|
|
288
|
+
| `search_docs` | Find documents by name |
|
289
|
+
| `get_doc_content` | Extract document text |
|
290
|
+
| `list_docs_in_folder` | List docs in folder |
|
291
|
+
| `create_doc` | Create new documents |
|
292
|
+
|
293
|
+
### 📊 Google Sheets ([`sheets_tools.py`](gsheets/sheets_tools.py))
|
294
|
+
|
295
|
+
| Tool | Description |
|
296
|
+
|------|-------------|
|
297
|
+
| `list_spreadsheets` | List accessible spreadsheets |
|
298
|
+
| `get_spreadsheet_info` | Get spreadsheet metadata |
|
299
|
+
| `read_sheet_values` | Read cell ranges |
|
300
|
+
| `modify_sheet_values` | Write/update/clear cells |
|
301
|
+
| `create_spreadsheet` | Create new spreadsheets |
|
302
|
+
| `create_sheet` | Add sheets to existing files |
|
303
|
+
|
304
|
+
### 📝 Google Forms ([`forms_tools.py`](gforms/forms_tools.py))
|
305
|
+
|
306
|
+
| Tool | Description |
|
307
|
+
|------|-------------|
|
308
|
+
| `create_form` | Create new forms with title and description |
|
309
|
+
| `get_form` | Retrieve form details, questions, and URLs |
|
310
|
+
| `set_publish_settings` | Configure form template and authentication settings |
|
311
|
+
| `get_form_response` | Get individual form response details |
|
312
|
+
| `list_form_responses` | List all responses to a form with pagination |
|
313
|
+
|
314
|
+
### 💬 Google Chat ([`chat_tools.py`](gchat/chat_tools.py))
|
315
|
+
|
316
|
+
| Tool | Description |
|
317
|
+
|------|-------------|
|
318
|
+
| `list_spaces` | List chat spaces/rooms |
|
319
|
+
| `get_messages` | Retrieve space messages |
|
320
|
+
| `send_message` | Send messages to spaces |
|
321
|
+
| `search_messages` | Search across chat history |
|
322
|
+
|
323
|
+
---
|
324
|
+
|
325
|
+
## 🛠️ Development
|
326
|
+
|
327
|
+
### Project Structure
|
328
|
+
|
329
|
+
```
|
330
|
+
google_workspace_mcp/
|
331
|
+
├── auth/ # Authentication system with decorators
|
332
|
+
├── core/ # MCP server and utilities
|
333
|
+
├── g{service}/ # Service-specific tools
|
334
|
+
├── main.py # Server entry point
|
335
|
+
├── client_secret.json # OAuth credentials (not committed)
|
336
|
+
└── pyproject.toml # Dependencies
|
337
|
+
```
|
338
|
+
|
339
|
+
### Adding New Tools
|
340
|
+
|
341
|
+
```python
|
342
|
+
from auth.service_decorator import require_google_service
|
343
|
+
|
344
|
+
@require_google_service("drive", "drive_read") # Service + scope group
|
345
|
+
async def your_new_tool(service, param1: str, param2: int = 10):
|
346
|
+
"""Tool description"""
|
347
|
+
# service is automatically injected and cached
|
348
|
+
result = service.files().list().execute()
|
349
|
+
return result # Return native Python objects
|
350
|
+
```
|
351
|
+
|
352
|
+
### Architecture Highlights
|
353
|
+
|
354
|
+
- **Service Caching**: 30-minute TTL reduces authentication overhead
|
355
|
+
- **Scope Management**: Centralized in `SCOPE_GROUPS` for easy maintenance
|
356
|
+
- **Error Handling**: Native exceptions instead of manual error construction
|
357
|
+
- **Multi-Service Support**: `@require_multiple_services()` for complex tools
|
358
|
+
|
359
|
+
---
|
360
|
+
|
361
|
+
## 🔒 Security
|
362
|
+
|
363
|
+
- **Credentials**: Never commit `client_secret.json` or `.credentials/` directory
|
364
|
+
- **OAuth Callback**: Uses `http://localhost:8000/oauth2callback` for development (requires `OAUTHLIB_INSECURE_TRANSPORT=1`)
|
365
|
+
- **Transport-Aware Callbacks**: Stdio mode starts a minimal HTTP server only for OAuth, ensuring callbacks work in all modes
|
366
|
+
- **Production**: Use HTTPS for callback URIs and configure accordingly
|
367
|
+
- **Network Exposure**: Consider authentication when using `mcpo` over networks
|
368
|
+
- **Scope Minimization**: Tools request only necessary permissions
|
369
|
+
|
370
|
+
---
|
371
|
+
|
372
|
+
## 🌐 Integration with Open WebUI
|
373
|
+
|
374
|
+
To use this server as a tool provider within Open WebUI:
|
375
|
+
|
376
|
+
### 1. Create MCPO Configuration
|
377
|
+
|
378
|
+
Create a file named `config.json` with the following structure to have `mcpo` make the streamable HTTP endpoint available as an OpenAPI spec tool:
|
379
|
+
|
380
|
+
```json
|
381
|
+
{
|
382
|
+
"mcpServers": {
|
383
|
+
"google_workspace": {
|
384
|
+
"type": "streamablehttp",
|
385
|
+
"url": "http://localhost:8000/mcp"
|
386
|
+
}
|
387
|
+
}
|
388
|
+
}
|
389
|
+
```
|
390
|
+
|
391
|
+
### 2. Start the MCPO Server
|
392
|
+
|
393
|
+
```bash
|
394
|
+
mcpo --port 8001 --config config.json --api-key "your-optional-secret-key"
|
395
|
+
```
|
396
|
+
|
397
|
+
This command starts the `mcpo` proxy, serving your active (assuming port 8000) Google Workspace MCP on port 8001.
|
398
|
+
|
399
|
+
### 3. Configure Open WebUI
|
400
|
+
|
401
|
+
1. Navigate to your Open WebUI settings
|
402
|
+
2. Go to **"Connections"** → **"Tools"**
|
403
|
+
3. Click **"Add Tool"**
|
404
|
+
4. Enter the **Server URL**: `http://localhost:8001/google_workspace` (matching the mcpo base URL and server name from config.json)
|
405
|
+
5. If you used an `--api-key` with mcpo, enter it as the **API Key**
|
406
|
+
6. Save the configuration
|
407
|
+
|
408
|
+
The Google Workspace tools should now be available when interacting with models in Open WebUI.
|
409
|
+
|
410
|
+
---
|
411
|
+
|
412
|
+
## 📄 License
|
413
|
+
|
414
|
+
MIT License - see `LICENSE` file for details.
|
415
|
+
|
416
|
+
---
|
417
|
+
|
418
|
+
<div align="center">
|
419
|
+
<img width="810" alt="Gmail Integration" src="https://github.com/user-attachments/assets/656cea40-1f66-40c1-b94c-5a2c900c969d" />
|
420
|
+
<img width="810" alt="Calendar Management" src="https://github.com/user-attachments/assets/d3c2a834-fcca-4dc5-8990-6d6dc1d96048" />
|
421
|
+
<img width="842" alt="Batch Emails" src="https://github.com/user-attachments/assets/0876c789-7bcc-4414-a144-6c3f0aaffc06" />
|
422
|
+
</div>
|
@@ -4,12 +4,14 @@
|
|
4
4
|
|
5
5
|
[](https://opensource.org/licenses/MIT)
|
6
6
|
[](https://www.python.org/downloads/)
|
7
|
+
[](https://pypi.org/project/workspace-mcp/)
|
7
8
|
[](https://github.com/astral-sh/uv)
|
8
9
|
[](https://workspacemcp.com)
|
10
|
+
[](https://mseep.ai/app/eebbc4a6-0f8c-41b2-ace8-038e5516dba0)
|
9
11
|
|
10
|
-
**
|
12
|
+
**This is the single most feature-complete Google Workspace MCP server**
|
11
13
|
|
12
|
-
*
|
14
|
+
*Full natural language control over Google Calendar, Drive, Gmail, Docs, Sheets, Slides, Forms, and Chat through all MCP clients, AI assistants and developer tools*
|
13
15
|
|
14
16
|
</div>
|
15
17
|
|
@@ -56,13 +58,26 @@ A production-ready MCP server that integrates all major Google Workspace service
|
|
56
58
|
|
57
59
|
## 🚀 Quick Start
|
58
60
|
|
59
|
-
###
|
61
|
+
### Simplest Start (uvx - Recommended)
|
60
62
|
|
61
|
-
|
62
|
-
|
63
|
-
|
63
|
+
Run instantly without installation:
|
64
|
+
|
65
|
+
```bash
|
66
|
+
# Start the server with all Google Workspace tools
|
67
|
+
uvx workspace-mcp
|
68
|
+
|
69
|
+
# Start with specific tools only
|
70
|
+
uvx workspace-mcp --tools gmail drive calendar
|
64
71
|
|
65
|
-
|
72
|
+
# Start in HTTP mode for debugging
|
73
|
+
uvx workspace-mcp --transport streamable-http
|
74
|
+
```
|
75
|
+
|
76
|
+
*Requires Python 3.11+ and [uvx](https://github.com/astral-sh/uv). The package is available on [PyPI](https://pypi.org/project/workspace-mcp).*
|
77
|
+
|
78
|
+
### Development Installation
|
79
|
+
|
80
|
+
For development or customization:
|
66
81
|
|
67
82
|
```bash
|
68
83
|
git clone https://github.com/taylorwilsdon/google_workspace_mcp.git
|
@@ -70,12 +85,19 @@ cd google_workspace_mcp
|
|
70
85
|
uv run main.py
|
71
86
|
```
|
72
87
|
|
88
|
+
### Prerequisites
|
89
|
+
|
90
|
+
- **Python 3.11+**
|
91
|
+
- **[uvx](https://github.com/astral-sh/uv)** (for instant installation) or [uv](https://github.com/astral-sh/uv) (for development)
|
92
|
+
- **Google Cloud Project** with OAuth 2.0 credentials
|
93
|
+
|
73
94
|
### Configuration
|
74
95
|
|
75
96
|
1. **Google Cloud Setup**:
|
76
97
|
- Create OAuth 2.0 credentials (web application) in [Google Cloud Console](https://console.cloud.google.com/)
|
77
98
|
- Enable APIs: Calendar, Drive, Gmail, Docs, Sheets, Slides, Forms, Chat
|
78
99
|
- Download credentials as `client_secret.json` in project root
|
100
|
+
- To use a different location for `client_secret.json`, you can set the `GOOGLE_CLIENT_SECRETS` environment variable with that path
|
79
101
|
- Add redirect URI: `http://localhost:8000/oauth2callback`
|
80
102
|
|
81
103
|
2. **Environment**:
|
@@ -106,8 +128,8 @@ uv run main.py --tools sheets docs
|
|
106
128
|
uv run main.py --single-user --tools gmail # Can combine with other flags
|
107
129
|
|
108
130
|
# Docker
|
109
|
-
docker build -t
|
110
|
-
docker run -p 8000:8000 -v $(pwd):/app
|
131
|
+
docker build -t workspace-mcp .
|
132
|
+
docker run -p 8000:8000 -v $(pwd):/app workspace-mcp --transport streamable-http
|
111
133
|
```
|
112
134
|
|
113
135
|
**Available Tools for `--tools` flag**: `gmail`, `drive`, `calendar`, `docs`, `sheets`, `forms`, `chat`
|
@@ -129,6 +151,18 @@ python install_claude.py
|
|
129
151
|
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
130
152
|
3. Add the server configuration:
|
131
153
|
|
154
|
+
```json
|
155
|
+
{
|
156
|
+
"mcpServers": {
|
157
|
+
"google_workspace": {
|
158
|
+
"command": "uvx",
|
159
|
+
"args": ["workspace-mcp"]
|
160
|
+
}
|
161
|
+
}
|
162
|
+
}
|
163
|
+
```
|
164
|
+
|
165
|
+
**Alternative (Development Installation)**:
|
132
166
|
```json
|
133
167
|
{
|
134
168
|
"mcpServers": {
|
@@ -193,29 +193,37 @@ def require_google_service(
|
|
193
193
|
# Original authentication logic is handled automatically
|
194
194
|
"""
|
195
195
|
def decorator(func: Callable) -> Callable:
|
196
|
+
# Inspect the original function signature
|
197
|
+
original_sig = inspect.signature(func)
|
198
|
+
params = list(original_sig.parameters.values())
|
199
|
+
|
200
|
+
# The decorated function must have 'service' as its first parameter.
|
201
|
+
if not params or params[0].name != 'service':
|
202
|
+
raise TypeError(
|
203
|
+
f"Function '{func.__name__}' decorated with @require_google_service "
|
204
|
+
"must have 'service' as its first parameter."
|
205
|
+
)
|
206
|
+
|
207
|
+
# Create a new signature for the wrapper that excludes the 'service' parameter.
|
208
|
+
# This is the signature that FastMCP will see.
|
209
|
+
wrapper_sig = original_sig.replace(parameters=params[1:])
|
210
|
+
|
196
211
|
@wraps(func)
|
197
212
|
async def wrapper(*args, **kwargs):
|
198
|
-
#
|
199
|
-
|
200
|
-
param_names = list(sig.parameters.keys())
|
213
|
+
# Note: `args` and `kwargs` are now the arguments for the *wrapper*,
|
214
|
+
# which does not include 'service'.
|
201
215
|
|
202
|
-
#
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
else:
|
207
|
-
# Look for user_google_email in positional args
|
208
|
-
try:
|
209
|
-
user_email_index = param_names.index('user_google_email')
|
210
|
-
if user_email_index < len(args):
|
211
|
-
user_google_email = args[user_email_index]
|
212
|
-
except ValueError:
|
213
|
-
pass
|
216
|
+
# Extract user_google_email from the arguments passed to the wrapper
|
217
|
+
bound_args = wrapper_sig.bind(*args, **kwargs)
|
218
|
+
bound_args.apply_defaults()
|
219
|
+
user_google_email = bound_args.arguments.get('user_google_email')
|
214
220
|
|
215
221
|
if not user_google_email:
|
216
|
-
|
222
|
+
# This should ideally not be reached if 'user_google_email' is a required parameter
|
223
|
+
# in the function signature, but it's a good safeguard.
|
224
|
+
raise Exception("'user_google_email' parameter is required but was not found.")
|
217
225
|
|
218
|
-
# Get service configuration
|
226
|
+
# Get service configuration from the decorator's arguments
|
219
227
|
if service_type not in SERVICE_CONFIGS:
|
220
228
|
raise Exception(f"Unknown service type: {service_type}")
|
221
229
|
|
@@ -226,7 +234,7 @@ def require_google_service(
|
|
226
234
|
# Resolve scopes
|
227
235
|
resolved_scopes = _resolve_scopes(scopes)
|
228
236
|
|
229
|
-
#
|
237
|
+
# --- Service Caching and Authentication Logic (largely unchanged) ---
|
230
238
|
service = None
|
231
239
|
actual_user_email = user_google_email
|
232
240
|
|
@@ -236,7 +244,6 @@ def require_google_service(
|
|
236
244
|
if cached_result:
|
237
245
|
service, actual_user_email = cached_result
|
238
246
|
|
239
|
-
# If not cached, authenticate
|
240
247
|
if service is None:
|
241
248
|
try:
|
242
249
|
tool_name = func.__name__
|
@@ -247,30 +254,22 @@ def require_google_service(
|
|
247
254
|
user_google_email=user_google_email,
|
248
255
|
required_scopes=resolved_scopes,
|
249
256
|
)
|
250
|
-
|
251
|
-
# Cache the service if caching is enabled
|
252
257
|
if cache_enabled:
|
253
258
|
cache_key = _get_cache_key(user_google_email, service_name, service_version, resolved_scopes)
|
254
259
|
_cache_service(cache_key, service, actual_user_email)
|
255
|
-
|
256
260
|
except GoogleAuthenticationError as e:
|
257
261
|
raise Exception(str(e))
|
258
262
|
|
259
|
-
#
|
260
|
-
if 'service' in param_names:
|
261
|
-
kwargs['service'] = service
|
262
|
-
else:
|
263
|
-
# Insert service as first positional argument
|
264
|
-
args = (service,) + args
|
265
|
-
|
266
|
-
# Call the original function with refresh error handling
|
263
|
+
# --- Call the original function with the service object injected ---
|
267
264
|
try:
|
268
|
-
|
265
|
+
# Prepend the fetched service object to the original arguments
|
266
|
+
return await func(service, *args, **kwargs)
|
269
267
|
except RefreshError as e:
|
270
|
-
# Handle token refresh errors gracefully
|
271
268
|
error_message = _handle_token_refresh_error(e, actual_user_email, service_name)
|
272
269
|
raise Exception(error_message)
|
273
270
|
|
271
|
+
# Set the wrapper's signature to the one without 'service'
|
272
|
+
wrapper.__signature__ = wrapper_sig
|
274
273
|
return wrapper
|
275
274
|
return decorator
|
276
275
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import logging
|
2
2
|
import os
|
3
|
-
from typing import
|
3
|
+
from typing import Optional
|
4
4
|
from importlib import metadata
|
5
5
|
|
6
6
|
from fastapi import Header
|
@@ -86,18 +86,17 @@ async def health_check(request: Request):
|
|
86
86
|
"""Health check endpoint for container orchestration."""
|
87
87
|
from fastapi.responses import JSONResponse
|
88
88
|
try:
|
89
|
-
version = metadata.version("
|
89
|
+
version = metadata.version("workspace-mcp")
|
90
90
|
except metadata.PackageNotFoundError:
|
91
91
|
version = "dev"
|
92
92
|
return JSONResponse({
|
93
93
|
"status": "healthy",
|
94
|
-
"service": "
|
94
|
+
"service": "workspace-mcp",
|
95
95
|
"version": version,
|
96
96
|
"transport": _current_transport_mode
|
97
97
|
})
|
98
98
|
|
99
99
|
|
100
|
-
# Register OAuth callback as a custom route
|
101
100
|
@server.custom_route("/oauth2callback", methods=["GET"])
|
102
101
|
async def oauth2_callback(request: Request) -> HTMLResponse:
|
103
102
|
"""
|
@@ -105,8 +104,6 @@ async def oauth2_callback(request: Request) -> HTMLResponse:
|
|
105
104
|
This endpoint exchanges the authorization code for credentials and saves them.
|
106
105
|
It then displays a success or error page to the user.
|
107
106
|
"""
|
108
|
-
# State is used by google-auth-library for CSRF protection and should be present.
|
109
|
-
# We don't need to track it ourselves in this simplified flow.
|
110
107
|
state = request.query_params.get("state")
|
111
108
|
code = request.query_params.get("code")
|
112
109
|
error = request.query_params.get("error")
|
@@ -122,7 +119,6 @@ async def oauth2_callback(request: Request) -> HTMLResponse:
|
|
122
119
|
return create_error_response(error_message)
|
123
120
|
|
124
121
|
try:
|
125
|
-
# Use the centralized CONFIG_CLIENT_SECRETS_PATH
|
126
122
|
client_secrets_path = CONFIG_CLIENT_SECRETS_PATH
|
127
123
|
if not os.path.exists(client_secrets_path):
|
128
124
|
logger.error(f"OAuth client secrets file not found at {client_secrets_path}")
|
@@ -207,13 +203,10 @@ async def start_google_auth(
|
|
207
203
|
if not ensure_oauth_callback_available(_current_transport_mode, WORKSPACE_MCP_PORT, WORKSPACE_MCP_BASE_URI):
|
208
204
|
raise Exception("Failed to start OAuth callback server. Please try again.")
|
209
205
|
|
210
|
-
# Use the centralized start_auth_flow from auth.google_auth
|
211
206
|
auth_result = await start_auth_flow(
|
212
207
|
mcp_session_id=mcp_session_id,
|
213
208
|
user_google_email=user_google_email,
|
214
209
|
service_name=service_name,
|
215
210
|
redirect_uri=redirect_uri
|
216
211
|
)
|
217
|
-
|
218
|
-
# auth_result is now a plain string, not a CallToolResult
|
219
212
|
return auth_result
|