workspace-mcp 1.0.2__tar.gz → 1.0.4__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 → workspace_mcp-1.0.4}/PKG-INFO +78 -11
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/README.md +77 -10
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/auth/google_auth.py +120 -12
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/auth/oauth_callback_server.py +7 -3
- workspace_mcp-1.0.4/core/comments.py +257 -0
- workspace_mcp-1.0.4/core/context.py +22 -0
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/core/server.py +7 -8
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/gdocs/docs_tools.py +11 -0
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/gsheets/sheets_tools.py +11 -0
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/gslides/slides_tools.py +16 -1
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/pyproject.toml +1 -1
- workspace_mcp-1.0.4/tests/test_auth.py +115 -0
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/workspace_mcp.egg-info/PKG-INFO +78 -11
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/workspace_mcp.egg-info/SOURCES.txt +3 -0
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/LICENSE +0 -0
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/auth/__init__.py +0 -0
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/auth/oauth_responses.py +0 -0
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/auth/scopes.py +0 -0
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/auth/service_decorator.py +0 -0
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/core/__init__.py +0 -0
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/core/utils.py +0 -0
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/gcalendar/__init__.py +0 -0
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/gcalendar/calendar_tools.py +0 -0
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/gchat/__init__.py +0 -0
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/gchat/chat_tools.py +0 -0
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/gdocs/__init__.py +0 -0
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/gdrive/__init__.py +0 -0
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/gdrive/drive_tools.py +0 -0
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/gforms/__init__.py +0 -0
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/gforms/forms_tools.py +0 -0
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/gmail/__init__.py +0 -0
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/gmail/gmail_tools.py +0 -0
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/gsheets/__init__.py +0 -0
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/gslides/__init__.py +0 -0
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/main.py +0 -0
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/setup.cfg +0 -0
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/workspace_mcp.egg-info/dependency_links.txt +0 -0
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/workspace_mcp.egg-info/entry_points.txt +0 -0
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/workspace_mcp.egg-info/requires.txt +0 -0
- {workspace_mcp-1.0.2 → workspace_mcp-1.0.4}/workspace_mcp.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: workspace-mcp
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.4
|
4
4
|
Summary: Comprehensive, highly performant Google Workspace Streamable HTTP & SSE MCP Server for Calendar, Gmail, Docs, Sheets, Slides & Drive
|
5
5
|
Author-email: Taylor Wilsdon <taylor@taylorwilsdon.com>
|
6
6
|
License: MIT
|
@@ -76,6 +76,14 @@ Dynamic: license-file
|
|
76
76
|
|
77
77
|
---
|
78
78
|
|
79
|
+
### A quick plug for AI-Enhanced Docs
|
80
|
+
|
81
|
+
> **This README was crafted with AI assistance, and here's why that matters**
|
82
|
+
>
|
83
|
+
> As a solo developer building open source tools that may only ever serve my own needs, 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.
|
84
|
+
>
|
85
|
+
> In this case, Sonnet 4 took a pass & a human (me) verified them 6/28/25.
|
86
|
+
|
79
87
|
|
80
88
|
## 🌐 Overview
|
81
89
|
|
@@ -87,9 +95,9 @@ A production-ready MCP server that integrates all major Google Workspace service
|
|
87
95
|
- **📅 Google Calendar**: Full calendar management with event CRUD operations
|
88
96
|
- **📁 Google Drive**: File operations with native Microsoft Office format support (.docx, .xlsx)
|
89
97
|
- **📧 Gmail**: Complete email management with search, send, and draft capabilities
|
90
|
-
- **📄 Google Docs**: Document operations including content extraction and
|
91
|
-
- **📊 Google Sheets**: Comprehensive spreadsheet management with flexible cell operations
|
92
|
-
- **🖼️ Google Slides**: Presentation management with slide creation, updates, and
|
98
|
+
- **📄 Google Docs**: Document operations including content extraction, creation, and comment management
|
99
|
+
- **📊 Google Sheets**: Comprehensive spreadsheet management with flexible cell operations and comment management
|
100
|
+
- **🖼️ Google Slides**: Presentation management with slide creation, updates, content manipulation, and comment management
|
93
101
|
- **📝 Google Forms**: Form creation, retrieval, publish settings, and response management
|
94
102
|
- **💬 Google Chat**: Space management and messaging capabilities
|
95
103
|
- **🔄 Multiple Transports**: HTTP with SSE fallback, OpenAPI compatibility via `mcpo`
|
@@ -102,9 +110,13 @@ A production-ready MCP server that integrates all major Google Workspace service
|
|
102
110
|
|
103
111
|
### Simplest Start (uvx - Recommended)
|
104
112
|
|
105
|
-
Run instantly without installation
|
113
|
+
> Run instantly without manual installation - you must configure OAuth credentials when using uvx. You can use either environment variables (recommended for production) or set the `GOOGLE_CLIENT_SECRET_PATH` (or legacy `GOOGLE_CLIENT_SECRETS`) environment variable to point to your `client_secret.json` file.
|
106
114
|
|
107
115
|
```bash
|
116
|
+
# Set OAuth credentials via environment variables (recommended)
|
117
|
+
export GOOGLE_OAUTH_CLIENT_ID="your-client-id.apps.googleusercontent.com"
|
118
|
+
export GOOGLE_OAUTH_CLIENT_SECRET="your-client-secret"
|
119
|
+
|
108
120
|
# Start the server with all Google Workspace tools
|
109
121
|
uvx workspace-mcp
|
110
122
|
|
@@ -138,19 +150,43 @@ uv run main.py
|
|
138
150
|
1. **Google Cloud Setup**:
|
139
151
|
- Create OAuth 2.0 credentials (web application) in [Google Cloud Console](https://console.cloud.google.com/)
|
140
152
|
- 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
153
|
- Add redirect URI: `http://localhost:8000/oauth2callback`
|
154
|
+
- Configure credentials using one of these methods:
|
155
|
+
|
156
|
+
**Option A: Environment Variables (Recommended for Production)**
|
157
|
+
```bash
|
158
|
+
export GOOGLE_OAUTH_CLIENT_ID="your-client-id.apps.googleusercontent.com"
|
159
|
+
export GOOGLE_OAUTH_CLIENT_SECRET="your-client-secret"
|
160
|
+
export GOOGLE_OAUTH_REDIRECT_URI="http://localhost:8000/oauth2callback" # Optional
|
161
|
+
```
|
162
|
+
|
163
|
+
**Option B: File-based (Traditional)**
|
164
|
+
- Download credentials as `client_secret.json` in project root
|
165
|
+
- To use a different location, set `GOOGLE_CLIENT_SECRET_PATH` (or legacy `GOOGLE_CLIENT_SECRETS`) environment variable with the file path
|
166
|
+
|
167
|
+
**Credential Loading Priority**:
|
168
|
+
1. Environment variables (`GOOGLE_OAUTH_CLIENT_ID`, `GOOGLE_OAUTH_CLIENT_SECRET`)
|
169
|
+
2. File specified by `GOOGLE_CLIENT_SECRET_PATH` or `GOOGLE_CLIENT_SECRETS` environment variable
|
170
|
+
3. Default file (`client_secret.json` in project root)
|
171
|
+
|
172
|
+
**Why Environment Variables?**
|
173
|
+
- ✅ Containerized deployments (Docker, Kubernetes)
|
174
|
+
- ✅ Cloud platforms (Heroku, Railway, etc.)
|
175
|
+
- ✅ CI/CD pipelines
|
176
|
+
- ✅ No secrets in version control
|
177
|
+
- ✅ Easy credential rotation
|
144
178
|
|
145
179
|
2. **Environment**:
|
146
180
|
```bash
|
147
181
|
export OAUTHLIB_INSECURE_TRANSPORT=1 # Development only
|
182
|
+
export USER_GOOGLE_EMAIL=your.email@gmail.com # Optional: Default email for auth - use this for single user setups and you won't need to set your email in system prompt for magic auth
|
148
183
|
```
|
149
184
|
|
150
185
|
3. **Server Configuration**:
|
151
186
|
The server's base URL and port can be customized using environment variables:
|
152
187
|
- `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
188
|
- `WORKSPACE_MCP_PORT`: Sets the port the server listens on (default: 8000). This affects the server_url, port, and OAUTH_REDIRECT_URI.
|
189
|
+
- `USER_GOOGLE_EMAIL`: Optional default email for authentication flows. If set, the LLM won't need to specify your email when calling `start_google_auth`.
|
154
190
|
|
155
191
|
### Start the Server
|
156
192
|
|
@@ -198,7 +234,11 @@ python install_claude.py
|
|
198
234
|
"mcpServers": {
|
199
235
|
"google_workspace": {
|
200
236
|
"command": "uvx",
|
201
|
-
"args": ["workspace-mcp"]
|
237
|
+
"args": ["workspace-mcp"],
|
238
|
+
"env": {
|
239
|
+
"GOOGLE_OAUTH_CLIENT_ID": "your-client-id.apps.googleusercontent.com",
|
240
|
+
"GOOGLE_OAUTH_CLIENT_SECRET": "your-client-secret"
|
241
|
+
}
|
202
242
|
}
|
203
243
|
}
|
204
244
|
}
|
@@ -211,7 +251,11 @@ python install_claude.py
|
|
211
251
|
"google_workspace": {
|
212
252
|
"command": "uv",
|
213
253
|
"args": ["run", "main.py"],
|
214
|
-
"cwd": "/path/to/google_workspace_mcp"
|
254
|
+
"cwd": "/path/to/google_workspace_mcp",
|
255
|
+
"env": {
|
256
|
+
"GOOGLE_OAUTH_CLIENT_ID": "your-client-id.apps.googleusercontent.com",
|
257
|
+
"GOOGLE_OAUTH_CLIENT_SECRET": "your-client-secret"
|
258
|
+
}
|
215
259
|
}
|
216
260
|
}
|
217
261
|
}
|
@@ -259,7 +303,8 @@ When calling a tool:
|
|
259
303
|
|------|-------------|
|
260
304
|
| `list_calendars` | List accessible calendars |
|
261
305
|
| `get_events` | Retrieve events with time range filtering |
|
262
|
-
| `
|
306
|
+
| `get_event` | Fetch detailed information of a single event by ID |
|
307
|
+
| `create_event` | Create events (all-day or timed) with optional Drive file attachments |
|
263
308
|
| `modify_event` | Update existing events |
|
264
309
|
| `delete_event` | Remove events |
|
265
310
|
|
@@ -270,7 +315,7 @@ When calling a tool:
|
|
270
315
|
| `search_drive_files` | Search files with query syntax |
|
271
316
|
| `get_drive_file_content` | Read file content (supports Office formats) |
|
272
317
|
| `list_drive_items` | List folder contents |
|
273
|
-
| `create_drive_file` | Create new files |
|
318
|
+
| `create_drive_file` | Create new files or fetch content from public URLs |
|
274
319
|
|
275
320
|
### 📧 Gmail ([`gmail_tools.py`](gmail/gmail_tools.py))
|
276
321
|
|
@@ -289,6 +334,10 @@ When calling a tool:
|
|
289
334
|
| `get_doc_content` | Extract document text |
|
290
335
|
| `list_docs_in_folder` | List docs in folder |
|
291
336
|
| `create_doc` | Create new documents |
|
337
|
+
| `read_doc_comments` | Read all comments and replies |
|
338
|
+
| `create_doc_comment` | Create new comments |
|
339
|
+
| `reply_to_comment` | Reply to existing comments |
|
340
|
+
| `resolve_comment` | Resolve comments |
|
292
341
|
|
293
342
|
### 📊 Google Sheets ([`sheets_tools.py`](gsheets/sheets_tools.py))
|
294
343
|
|
@@ -300,6 +349,24 @@ When calling a tool:
|
|
300
349
|
| `modify_sheet_values` | Write/update/clear cells |
|
301
350
|
| `create_spreadsheet` | Create new spreadsheets |
|
302
351
|
| `create_sheet` | Add sheets to existing files |
|
352
|
+
| `read_sheet_comments` | Read all comments and replies |
|
353
|
+
| `create_sheet_comment` | Create new comments |
|
354
|
+
| `reply_to_sheet_comment` | Reply to existing comments |
|
355
|
+
| `resolve_sheet_comment` | Resolve comments |
|
356
|
+
|
357
|
+
### 🖼️ Google Slides ([`slides_tools.py`](gslides/slides_tools.py))
|
358
|
+
|
359
|
+
| Tool | Description |
|
360
|
+
|------|-------------|
|
361
|
+
| `create_presentation` | Create new presentations |
|
362
|
+
| `get_presentation` | Retrieve presentation details |
|
363
|
+
| `batch_update_presentation` | Apply multiple updates at once |
|
364
|
+
| `get_page` | Get specific slide information |
|
365
|
+
| `get_page_thumbnail` | Generate slide thumbnails |
|
366
|
+
| `read_presentation_comments` | Read all comments and replies |
|
367
|
+
| `create_presentation_comment` | Create new comments |
|
368
|
+
| `reply_to_presentation_comment` | Reply to existing comments |
|
369
|
+
| `resolve_presentation_comment` | Resolve comments |
|
303
370
|
|
304
371
|
### 📝 Google Forms ([`forms_tools.py`](gforms/forms_tools.py))
|
305
372
|
|
@@ -34,6 +34,14 @@
|
|
34
34
|
|
35
35
|
---
|
36
36
|
|
37
|
+
### A quick plug for AI-Enhanced Docs
|
38
|
+
|
39
|
+
> **This README was crafted with AI assistance, and here's why that matters**
|
40
|
+
>
|
41
|
+
> As a solo developer building open source tools that may only ever serve my own needs, 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.
|
42
|
+
>
|
43
|
+
> In this case, Sonnet 4 took a pass & a human (me) verified them 6/28/25.
|
44
|
+
|
37
45
|
|
38
46
|
## 🌐 Overview
|
39
47
|
|
@@ -45,9 +53,9 @@ A production-ready MCP server that integrates all major Google Workspace service
|
|
45
53
|
- **📅 Google Calendar**: Full calendar management with event CRUD operations
|
46
54
|
- **📁 Google Drive**: File operations with native Microsoft Office format support (.docx, .xlsx)
|
47
55
|
- **📧 Gmail**: Complete email management with search, send, and draft capabilities
|
48
|
-
- **📄 Google Docs**: Document operations including content extraction and
|
49
|
-
- **📊 Google Sheets**: Comprehensive spreadsheet management with flexible cell operations
|
50
|
-
- **🖼️ Google Slides**: Presentation management with slide creation, updates, and
|
56
|
+
- **📄 Google Docs**: Document operations including content extraction, creation, and comment management
|
57
|
+
- **📊 Google Sheets**: Comprehensive spreadsheet management with flexible cell operations and comment management
|
58
|
+
- **🖼️ Google Slides**: Presentation management with slide creation, updates, content manipulation, and comment management
|
51
59
|
- **📝 Google Forms**: Form creation, retrieval, publish settings, and response management
|
52
60
|
- **💬 Google Chat**: Space management and messaging capabilities
|
53
61
|
- **🔄 Multiple Transports**: HTTP with SSE fallback, OpenAPI compatibility via `mcpo`
|
@@ -60,9 +68,13 @@ A production-ready MCP server that integrates all major Google Workspace service
|
|
60
68
|
|
61
69
|
### Simplest Start (uvx - Recommended)
|
62
70
|
|
63
|
-
Run instantly without installation
|
71
|
+
> Run instantly without manual installation - you must configure OAuth credentials when using uvx. You can use either environment variables (recommended for production) or set the `GOOGLE_CLIENT_SECRET_PATH` (or legacy `GOOGLE_CLIENT_SECRETS`) environment variable to point to your `client_secret.json` file.
|
64
72
|
|
65
73
|
```bash
|
74
|
+
# Set OAuth credentials via environment variables (recommended)
|
75
|
+
export GOOGLE_OAUTH_CLIENT_ID="your-client-id.apps.googleusercontent.com"
|
76
|
+
export GOOGLE_OAUTH_CLIENT_SECRET="your-client-secret"
|
77
|
+
|
66
78
|
# Start the server with all Google Workspace tools
|
67
79
|
uvx workspace-mcp
|
68
80
|
|
@@ -96,19 +108,43 @@ uv run main.py
|
|
96
108
|
1. **Google Cloud Setup**:
|
97
109
|
- Create OAuth 2.0 credentials (web application) in [Google Cloud Console](https://console.cloud.google.com/)
|
98
110
|
- Enable APIs: Calendar, Drive, Gmail, Docs, Sheets, Slides, Forms, Chat
|
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
|
101
111
|
- Add redirect URI: `http://localhost:8000/oauth2callback`
|
112
|
+
- Configure credentials using one of these methods:
|
113
|
+
|
114
|
+
**Option A: Environment Variables (Recommended for Production)**
|
115
|
+
```bash
|
116
|
+
export GOOGLE_OAUTH_CLIENT_ID="your-client-id.apps.googleusercontent.com"
|
117
|
+
export GOOGLE_OAUTH_CLIENT_SECRET="your-client-secret"
|
118
|
+
export GOOGLE_OAUTH_REDIRECT_URI="http://localhost:8000/oauth2callback" # Optional
|
119
|
+
```
|
120
|
+
|
121
|
+
**Option B: File-based (Traditional)**
|
122
|
+
- Download credentials as `client_secret.json` in project root
|
123
|
+
- To use a different location, set `GOOGLE_CLIENT_SECRET_PATH` (or legacy `GOOGLE_CLIENT_SECRETS`) environment variable with the file path
|
124
|
+
|
125
|
+
**Credential Loading Priority**:
|
126
|
+
1. Environment variables (`GOOGLE_OAUTH_CLIENT_ID`, `GOOGLE_OAUTH_CLIENT_SECRET`)
|
127
|
+
2. File specified by `GOOGLE_CLIENT_SECRET_PATH` or `GOOGLE_CLIENT_SECRETS` environment variable
|
128
|
+
3. Default file (`client_secret.json` in project root)
|
129
|
+
|
130
|
+
**Why Environment Variables?**
|
131
|
+
- ✅ Containerized deployments (Docker, Kubernetes)
|
132
|
+
- ✅ Cloud platforms (Heroku, Railway, etc.)
|
133
|
+
- ✅ CI/CD pipelines
|
134
|
+
- ✅ No secrets in version control
|
135
|
+
- ✅ Easy credential rotation
|
102
136
|
|
103
137
|
2. **Environment**:
|
104
138
|
```bash
|
105
139
|
export OAUTHLIB_INSECURE_TRANSPORT=1 # Development only
|
140
|
+
export USER_GOOGLE_EMAIL=your.email@gmail.com # Optional: Default email for auth - use this for single user setups and you won't need to set your email in system prompt for magic auth
|
106
141
|
```
|
107
142
|
|
108
143
|
3. **Server Configuration**:
|
109
144
|
The server's base URL and port can be customized using environment variables:
|
110
145
|
- `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.
|
111
146
|
- `WORKSPACE_MCP_PORT`: Sets the port the server listens on (default: 8000). This affects the server_url, port, and OAUTH_REDIRECT_URI.
|
147
|
+
- `USER_GOOGLE_EMAIL`: Optional default email for authentication flows. If set, the LLM won't need to specify your email when calling `start_google_auth`.
|
112
148
|
|
113
149
|
### Start the Server
|
114
150
|
|
@@ -156,7 +192,11 @@ python install_claude.py
|
|
156
192
|
"mcpServers": {
|
157
193
|
"google_workspace": {
|
158
194
|
"command": "uvx",
|
159
|
-
"args": ["workspace-mcp"]
|
195
|
+
"args": ["workspace-mcp"],
|
196
|
+
"env": {
|
197
|
+
"GOOGLE_OAUTH_CLIENT_ID": "your-client-id.apps.googleusercontent.com",
|
198
|
+
"GOOGLE_OAUTH_CLIENT_SECRET": "your-client-secret"
|
199
|
+
}
|
160
200
|
}
|
161
201
|
}
|
162
202
|
}
|
@@ -169,7 +209,11 @@ python install_claude.py
|
|
169
209
|
"google_workspace": {
|
170
210
|
"command": "uv",
|
171
211
|
"args": ["run", "main.py"],
|
172
|
-
"cwd": "/path/to/google_workspace_mcp"
|
212
|
+
"cwd": "/path/to/google_workspace_mcp",
|
213
|
+
"env": {
|
214
|
+
"GOOGLE_OAUTH_CLIENT_ID": "your-client-id.apps.googleusercontent.com",
|
215
|
+
"GOOGLE_OAUTH_CLIENT_SECRET": "your-client-secret"
|
216
|
+
}
|
173
217
|
}
|
174
218
|
}
|
175
219
|
}
|
@@ -217,7 +261,8 @@ When calling a tool:
|
|
217
261
|
|------|-------------|
|
218
262
|
| `list_calendars` | List accessible calendars |
|
219
263
|
| `get_events` | Retrieve events with time range filtering |
|
220
|
-
| `
|
264
|
+
| `get_event` | Fetch detailed information of a single event by ID |
|
265
|
+
| `create_event` | Create events (all-day or timed) with optional Drive file attachments |
|
221
266
|
| `modify_event` | Update existing events |
|
222
267
|
| `delete_event` | Remove events |
|
223
268
|
|
@@ -228,7 +273,7 @@ When calling a tool:
|
|
228
273
|
| `search_drive_files` | Search files with query syntax |
|
229
274
|
| `get_drive_file_content` | Read file content (supports Office formats) |
|
230
275
|
| `list_drive_items` | List folder contents |
|
231
|
-
| `create_drive_file` | Create new files |
|
276
|
+
| `create_drive_file` | Create new files or fetch content from public URLs |
|
232
277
|
|
233
278
|
### 📧 Gmail ([`gmail_tools.py`](gmail/gmail_tools.py))
|
234
279
|
|
@@ -247,6 +292,10 @@ When calling a tool:
|
|
247
292
|
| `get_doc_content` | Extract document text |
|
248
293
|
| `list_docs_in_folder` | List docs in folder |
|
249
294
|
| `create_doc` | Create new documents |
|
295
|
+
| `read_doc_comments` | Read all comments and replies |
|
296
|
+
| `create_doc_comment` | Create new comments |
|
297
|
+
| `reply_to_comment` | Reply to existing comments |
|
298
|
+
| `resolve_comment` | Resolve comments |
|
250
299
|
|
251
300
|
### 📊 Google Sheets ([`sheets_tools.py`](gsheets/sheets_tools.py))
|
252
301
|
|
@@ -258,6 +307,24 @@ When calling a tool:
|
|
258
307
|
| `modify_sheet_values` | Write/update/clear cells |
|
259
308
|
| `create_spreadsheet` | Create new spreadsheets |
|
260
309
|
| `create_sheet` | Add sheets to existing files |
|
310
|
+
| `read_sheet_comments` | Read all comments and replies |
|
311
|
+
| `create_sheet_comment` | Create new comments |
|
312
|
+
| `reply_to_sheet_comment` | Reply to existing comments |
|
313
|
+
| `resolve_sheet_comment` | Resolve comments |
|
314
|
+
|
315
|
+
### 🖼️ Google Slides ([`slides_tools.py`](gslides/slides_tools.py))
|
316
|
+
|
317
|
+
| Tool | Description |
|
318
|
+
|------|-------------|
|
319
|
+
| `create_presentation` | Create new presentations |
|
320
|
+
| `get_presentation` | Retrieve presentation details |
|
321
|
+
| `batch_update_presentation` | Apply multiple updates at once |
|
322
|
+
| `get_page` | Get specific slide information |
|
323
|
+
| `get_page_thumbnail` | Generate slide thumbnails |
|
324
|
+
| `read_presentation_comments` | Read all comments and replies |
|
325
|
+
| `create_presentation_comment` | Create new comments |
|
326
|
+
| `reply_to_presentation_comment` | Reply to existing comments |
|
327
|
+
| `resolve_presentation_comment` | Resolve comments |
|
261
328
|
|
262
329
|
### 📝 Google Forms ([`forms_tools.py`](gforms/forms_tools.py))
|
263
330
|
|
@@ -27,7 +27,7 @@ DEFAULT_CREDENTIALS_DIR = ".credentials"
|
|
27
27
|
# This should be more robust in a production system once OAuth2.1 is implemented in client.
|
28
28
|
_SESSION_CREDENTIALS_CACHE: Dict[str, Credentials] = {}
|
29
29
|
# Centralized Client Secrets Path Logic
|
30
|
-
_client_secrets_env = os.getenv("GOOGLE_CLIENT_SECRETS")
|
30
|
+
_client_secrets_env = os.getenv("GOOGLE_CLIENT_SECRET_PATH") or os.getenv("GOOGLE_CLIENT_SECRETS")
|
31
31
|
if _client_secrets_env:
|
32
32
|
CONFIG_CLIENT_SECRETS_PATH = _client_secrets_env
|
33
33
|
else:
|
@@ -151,22 +151,128 @@ def load_credentials_from_session(session_id: str) -> Optional[Credentials]:
|
|
151
151
|
logger.debug(f"No credentials found in session cache for session_id: {session_id}")
|
152
152
|
return credentials
|
153
153
|
|
154
|
+
def load_client_secrets_from_env() -> Optional[Dict[str, Any]]:
|
155
|
+
"""
|
156
|
+
Loads the client secrets from environment variables.
|
157
|
+
|
158
|
+
Environment variables used:
|
159
|
+
- GOOGLE_OAUTH_CLIENT_ID: OAuth 2.0 client ID
|
160
|
+
- GOOGLE_OAUTH_CLIENT_SECRET: OAuth 2.0 client secret
|
161
|
+
- GOOGLE_OAUTH_REDIRECT_URI: (optional) OAuth redirect URI
|
162
|
+
|
163
|
+
Returns:
|
164
|
+
Client secrets configuration dict compatible with Google OAuth library,
|
165
|
+
or None if required environment variables are not set.
|
166
|
+
"""
|
167
|
+
client_id = os.getenv("GOOGLE_OAUTH_CLIENT_ID")
|
168
|
+
client_secret = os.getenv("GOOGLE_OAUTH_CLIENT_SECRET")
|
169
|
+
redirect_uri = os.getenv("GOOGLE_OAUTH_REDIRECT_URI")
|
170
|
+
|
171
|
+
if client_id and client_secret:
|
172
|
+
# Create config structure that matches Google client secrets format
|
173
|
+
web_config = {
|
174
|
+
"client_id": client_id,
|
175
|
+
"client_secret": client_secret,
|
176
|
+
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
177
|
+
"token_uri": "https://oauth2.googleapis.com/token",
|
178
|
+
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs"
|
179
|
+
}
|
180
|
+
|
181
|
+
# Add redirect_uri if provided via environment variable
|
182
|
+
if redirect_uri:
|
183
|
+
web_config["redirect_uris"] = [redirect_uri]
|
184
|
+
|
185
|
+
# Return the full config structure expected by Google OAuth library
|
186
|
+
config = {"web": web_config}
|
187
|
+
|
188
|
+
logger.info("Loaded OAuth client credentials from environment variables")
|
189
|
+
return config
|
190
|
+
|
191
|
+
logger.debug("OAuth client credentials not found in environment variables")
|
192
|
+
return None
|
193
|
+
|
154
194
|
def load_client_secrets(client_secrets_path: str) -> Dict[str, Any]:
|
155
|
-
"""
|
195
|
+
"""
|
196
|
+
Loads the client secrets from environment variables (preferred) or from the client secrets file.
|
197
|
+
|
198
|
+
Priority order:
|
199
|
+
1. Environment variables (GOOGLE_OAUTH_CLIENT_ID, GOOGLE_OAUTH_CLIENT_SECRET)
|
200
|
+
2. File-based credentials at the specified path
|
201
|
+
|
202
|
+
Args:
|
203
|
+
client_secrets_path: Path to the client secrets JSON file (used as fallback)
|
204
|
+
|
205
|
+
Returns:
|
206
|
+
Client secrets configuration dict
|
207
|
+
|
208
|
+
Raises:
|
209
|
+
ValueError: If client secrets file has invalid format
|
210
|
+
IOError: If file cannot be read and no environment variables are set
|
211
|
+
"""
|
212
|
+
# First, try to load from environment variables
|
213
|
+
env_config = load_client_secrets_from_env()
|
214
|
+
if env_config:
|
215
|
+
# Extract the "web" config from the environment structure
|
216
|
+
return env_config["web"]
|
217
|
+
|
218
|
+
# Fall back to loading from file
|
156
219
|
try:
|
157
220
|
with open(client_secrets_path, 'r') as f:
|
158
221
|
client_config = json.load(f)
|
159
222
|
# The file usually contains a top-level key like "web" or "installed"
|
160
223
|
if "web" in client_config:
|
224
|
+
logger.info(f"Loaded OAuth client credentials from file: {client_secrets_path}")
|
161
225
|
return client_config["web"]
|
162
226
|
elif "installed" in client_config:
|
163
|
-
|
227
|
+
logger.info(f"Loaded OAuth client credentials from file: {client_secrets_path}")
|
228
|
+
return client_config["installed"]
|
164
229
|
else:
|
165
230
|
logger.error(f"Client secrets file {client_secrets_path} has unexpected format.")
|
166
231
|
raise ValueError("Invalid client secrets file format")
|
167
232
|
except (IOError, json.JSONDecodeError) as e:
|
168
233
|
logger.error(f"Error loading client secrets file {client_secrets_path}: {e}")
|
169
234
|
raise
|
235
|
+
def check_client_secrets() -> Optional[str]:
|
236
|
+
"""
|
237
|
+
Checks for the presence of OAuth client secrets, either as environment
|
238
|
+
variables or as a file.
|
239
|
+
|
240
|
+
Returns:
|
241
|
+
An error message string if secrets are not found, otherwise None.
|
242
|
+
"""
|
243
|
+
env_config = load_client_secrets_from_env()
|
244
|
+
if not env_config and not os.path.exists(CONFIG_CLIENT_SECRETS_PATH):
|
245
|
+
logger.error(f"OAuth client credentials not found. No environment variables set and no file at {CONFIG_CLIENT_SECRETS_PATH}")
|
246
|
+
return f"OAuth client credentials not found. Please set GOOGLE_OAUTH_CLIENT_ID and GOOGLE_OAUTH_CLIENT_SECRET environment variables or provide a client secrets file at {CONFIG_CLIENT_SECRETS_PATH}."
|
247
|
+
return None
|
248
|
+
|
249
|
+
def create_oauth_flow(scopes: List[str], redirect_uri: str, state: Optional[str] = None) -> Flow:
|
250
|
+
"""Creates an OAuth flow using environment variables or client secrets file."""
|
251
|
+
# Try environment variables first
|
252
|
+
env_config = load_client_secrets_from_env()
|
253
|
+
if env_config:
|
254
|
+
# Use client config directly
|
255
|
+
flow = Flow.from_client_config(
|
256
|
+
env_config,
|
257
|
+
scopes=scopes,
|
258
|
+
redirect_uri=redirect_uri,
|
259
|
+
state=state
|
260
|
+
)
|
261
|
+
logger.debug("Created OAuth flow from environment variables")
|
262
|
+
return flow
|
263
|
+
|
264
|
+
# Fall back to file-based config
|
265
|
+
if not os.path.exists(CONFIG_CLIENT_SECRETS_PATH):
|
266
|
+
raise FileNotFoundError(f"OAuth client secrets file not found at {CONFIG_CLIENT_SECRETS_PATH} and no environment variables set")
|
267
|
+
|
268
|
+
flow = Flow.from_client_secrets_file(
|
269
|
+
CONFIG_CLIENT_SECRETS_PATH,
|
270
|
+
scopes=scopes,
|
271
|
+
redirect_uri=redirect_uri,
|
272
|
+
state=state
|
273
|
+
)
|
274
|
+
logger.debug(f"Created OAuth flow from client secrets file: {CONFIG_CLIENT_SECRETS_PATH}")
|
275
|
+
return flow
|
170
276
|
|
171
277
|
# --- Core OAuth Logic ---
|
172
278
|
|
@@ -206,8 +312,7 @@ async def start_auth_flow(
|
|
206
312
|
OAUTH_STATE_TO_SESSION_ID_MAP[oauth_state] = mcp_session_id
|
207
313
|
logger.info(f"[start_auth_flow] Stored mcp_session_id '{mcp_session_id}' for oauth_state '{oauth_state}'.")
|
208
314
|
|
209
|
-
flow =
|
210
|
-
CONFIG_CLIENT_SECRETS_PATH, # Use module constant
|
315
|
+
flow = create_oauth_flow(
|
211
316
|
scopes=SCOPES, # Use global SCOPES
|
212
317
|
redirect_uri=redirect_uri, # Use passed redirect_uri
|
213
318
|
state=oauth_state
|
@@ -240,7 +345,7 @@ async def start_auth_flow(
|
|
240
345
|
return "\n".join(message_lines)
|
241
346
|
|
242
347
|
except FileNotFoundError as e:
|
243
|
-
error_text = f"OAuth client
|
348
|
+
error_text = f"OAuth client credentials not found: {e}. Please either:\n1. Set environment variables: GOOGLE_OAUTH_CLIENT_ID and GOOGLE_OAUTH_CLIENT_SECRET\n2. Ensure '{CONFIG_CLIENT_SECRETS_PATH}' file exists"
|
244
349
|
logger.error(error_text, exc_info=True)
|
245
350
|
raise Exception(error_text)
|
246
351
|
except Exception as e:
|
@@ -249,12 +354,12 @@ async def start_auth_flow(
|
|
249
354
|
raise Exception(error_text)
|
250
355
|
|
251
356
|
def handle_auth_callback(
|
252
|
-
client_secrets_path: str,
|
253
357
|
scopes: List[str],
|
254
358
|
authorization_response: str,
|
255
|
-
redirect_uri: str,
|
359
|
+
redirect_uri: str,
|
256
360
|
credentials_base_dir: str = DEFAULT_CREDENTIALS_DIR,
|
257
|
-
session_id: Optional[str] = None
|
361
|
+
session_id: Optional[str] = None,
|
362
|
+
client_secrets_path: Optional[str] = None # Deprecated: kept for backward compatibility
|
258
363
|
) -> Tuple[str, Credentials]:
|
259
364
|
"""
|
260
365
|
Handles the callback from Google, exchanges the code for credentials,
|
@@ -262,12 +367,12 @@ def handle_auth_callback(
|
|
262
367
|
and returns them.
|
263
368
|
|
264
369
|
Args:
|
265
|
-
client_secrets_path: Path to the Google client secrets JSON file.
|
266
370
|
scopes: List of OAuth scopes requested.
|
267
371
|
authorization_response: The full callback URL from Google.
|
268
372
|
redirect_uri: The redirect URI.
|
269
373
|
credentials_base_dir: Base directory for credential files.
|
270
374
|
session_id: Optional MCP session ID to associate with the credentials.
|
375
|
+
client_secrets_path: (Deprecated) Path to client secrets file. Ignored if environment variables are set.
|
271
376
|
|
272
377
|
Returns:
|
273
378
|
A tuple containing the user_google_email and the obtained Credentials object.
|
@@ -278,13 +383,16 @@ def handle_auth_callback(
|
|
278
383
|
HttpError: If fetching user info fails.
|
279
384
|
"""
|
280
385
|
try:
|
386
|
+
# Log deprecation warning if old parameter is used
|
387
|
+
if client_secrets_path:
|
388
|
+
logger.warning("The 'client_secrets_path' parameter is deprecated. Use GOOGLE_OAUTH_CLIENT_ID and GOOGLE_OAUTH_CLIENT_SECRET environment variables instead.")
|
389
|
+
|
281
390
|
# Allow HTTP for localhost in development
|
282
391
|
if 'OAUTHLIB_INSECURE_TRANSPORT' not in os.environ:
|
283
392
|
logger.warning("OAUTHLIB_INSECURE_TRANSPORT not set. Setting it for localhost development.")
|
284
393
|
os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1'
|
285
394
|
|
286
|
-
flow =
|
287
|
-
client_secrets_path,
|
395
|
+
flow = create_oauth_flow(
|
288
396
|
scopes=scopes,
|
289
397
|
redirect_uri=redirect_uri
|
290
398
|
)
|
@@ -15,7 +15,7 @@ import socket
|
|
15
15
|
from fastapi import FastAPI, Request
|
16
16
|
import uvicorn
|
17
17
|
|
18
|
-
from auth.google_auth import handle_auth_callback,
|
18
|
+
from auth.google_auth import handle_auth_callback, check_client_secrets
|
19
19
|
from auth.scopes import OAUTH_STATE_TO_SESSION_ID_MAP, SCOPES
|
20
20
|
from auth.oauth_responses import create_error_response, create_success_response, create_server_error_response
|
21
21
|
|
@@ -59,6 +59,11 @@ class MinimalOAuthServer:
|
|
59
59
|
return create_error_response(error_message)
|
60
60
|
|
61
61
|
try:
|
62
|
+
# Check if we have credentials available (environment variables or file)
|
63
|
+
error_message = check_client_secrets()
|
64
|
+
if error_message:
|
65
|
+
return create_server_error_response(error_message)
|
66
|
+
|
62
67
|
logger.info(f"OAuth callback: Received code (state: {state}). Attempting to exchange for tokens.")
|
63
68
|
|
64
69
|
mcp_session_id: Optional[str] = OAUTH_STATE_TO_SESSION_ID_MAP.pop(state, None)
|
@@ -69,7 +74,6 @@ class MinimalOAuthServer:
|
|
69
74
|
|
70
75
|
# Exchange code for credentials
|
71
76
|
verified_user_id, credentials = handle_auth_callback(
|
72
|
-
client_secrets_path=CONFIG_CLIENT_SECRETS_PATH,
|
73
77
|
scopes=SCOPES,
|
74
78
|
authorization_response=str(request.url),
|
75
79
|
redirect_uri=f"{self.base_uri}:{self.port}/oauth2callback",
|
@@ -106,7 +110,7 @@ class MinimalOAuthServer:
|
|
106
110
|
hostname = parsed_uri.hostname or 'localhost'
|
107
111
|
except Exception:
|
108
112
|
hostname = 'localhost'
|
109
|
-
|
113
|
+
|
110
114
|
try:
|
111
115
|
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
112
116
|
s.bind((hostname, self.port))
|