workspace-mcp 1.1.3__py3-none-any.whl → 1.1.4__py3-none-any.whl

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.
auth/scopes.py CHANGED
@@ -52,6 +52,10 @@ FORMS_RESPONSES_READONLY_SCOPE = 'https://www.googleapis.com/auth/forms.response
52
52
  SLIDES_SCOPE = 'https://www.googleapis.com/auth/presentations'
53
53
  SLIDES_READONLY_SCOPE = 'https://www.googleapis.com/auth/presentations.readonly'
54
54
 
55
+ # Google Tasks API scopes
56
+ TASKS_SCOPE = 'https://www.googleapis.com/auth/tasks'
57
+ TASKS_READONLY_SCOPE = 'https://www.googleapis.com/auth/tasks.readonly'
58
+
55
59
  # Base OAuth scopes required for user identification
56
60
  BASE_SCOPES = [
57
61
  USERINFO_EMAIL_SCOPE,
@@ -104,5 +108,10 @@ SLIDES_SCOPES = [
104
108
  SLIDES_READONLY_SCOPE
105
109
  ]
106
110
 
111
+ TASKS_SCOPES = [
112
+ TASKS_SCOPE,
113
+ TASKS_READONLY_SCOPE
114
+ ]
115
+
107
116
  # Combined scopes for all supported Google Workspace operations
108
- SCOPES = list(set(BASE_SCOPES + CALENDAR_SCOPES + DRIVE_SCOPES + GMAIL_SCOPES + DOCS_SCOPES + CHAT_SCOPES + SHEETS_SCOPES + FORMS_SCOPES + SLIDES_SCOPES))
117
+ SCOPES = list(set(BASE_SCOPES + CALENDAR_SCOPES + DRIVE_SCOPES + GMAIL_SCOPES + DOCS_SCOPES + CHAT_SCOPES + SHEETS_SCOPES + FORMS_SCOPES + SLIDES_SCOPES + TASKS_SCOPES))
auth/service_decorator.py CHANGED
@@ -18,7 +18,8 @@ from auth.scopes import (
18
18
  SHEETS_READONLY_SCOPE, SHEETS_WRITE_SCOPE,
19
19
  CHAT_READONLY_SCOPE, CHAT_WRITE_SCOPE, CHAT_SPACES_SCOPE,
20
20
  FORMS_BODY_SCOPE, FORMS_BODY_READONLY_SCOPE, FORMS_RESPONSES_READONLY_SCOPE,
21
- SLIDES_SCOPE, SLIDES_READONLY_SCOPE
21
+ SLIDES_SCOPE, SLIDES_READONLY_SCOPE,
22
+ TASKS_SCOPE, TASKS_READONLY_SCOPE
22
23
  )
23
24
 
24
25
  # Service configuration mapping
@@ -30,7 +31,8 @@ SERVICE_CONFIGS = {
30
31
  "sheets": {"service": "sheets", "version": "v4"},
31
32
  "chat": {"service": "chat", "version": "v1"},
32
33
  "forms": {"service": "forms", "version": "v1"},
33
- "slides": {"service": "slides", "version": "v1"}
34
+ "slides": {"service": "slides", "version": "v1"},
35
+ "tasks": {"service": "tasks", "version": "v1"}
34
36
  }
35
37
 
36
38
 
@@ -72,6 +74,10 @@ SCOPE_GROUPS = {
72
74
  # Slides scopes
73
75
  "slides": SLIDES_SCOPE,
74
76
  "slides_read": SLIDES_READONLY_SCOPE,
77
+
78
+ # Tasks scopes
79
+ "tasks": TASKS_SCOPE,
80
+ "tasks_read": TASKS_READONLY_SCOPE,
75
81
  }
76
82
 
77
83
  # Service cache: {cache_key: (service, cached_time, user_email)}
core/server.py CHANGED
@@ -49,6 +49,9 @@ from auth.scopes import (
49
49
  SLIDES_SCOPE,
50
50
  SLIDES_READONLY_SCOPE,
51
51
  SLIDES_SCOPES,
52
+ TASKS_SCOPE,
53
+ TASKS_READONLY_SCOPE,
54
+ TASKS_SCOPES,
52
55
  SCOPES
53
56
  )
54
57
 
gtasks/__init__.py ADDED
@@ -0,0 +1,5 @@
1
+ """
2
+ Google Tasks MCP Integration
3
+
4
+ This module provides MCP tools for interacting with Google Tasks API.
5
+ """
gtasks/tasks_tools.py ADDED
@@ -0,0 +1,732 @@
1
+ """
2
+ Google Tasks MCP Tools
3
+
4
+ This module provides MCP tools for interacting with Google Tasks API.
5
+ """
6
+
7
+ import logging
8
+ import asyncio
9
+ from typing import List, Optional, Dict, Any
10
+
11
+ from mcp import types
12
+ from googleapiclient.errors import HttpError
13
+
14
+ from auth.service_decorator import require_google_service
15
+ from core.server import server
16
+
17
+ logger = logging.getLogger(__name__)
18
+
19
+
20
+ @server.tool()
21
+ @require_google_service("tasks", "tasks_read")
22
+ async def list_task_lists(
23
+ service,
24
+ user_google_email: str,
25
+ max_results: Optional[int] = None,
26
+ page_token: Optional[str] = None
27
+ ) -> str:
28
+ """
29
+ List all task lists for the user.
30
+
31
+ Args:
32
+ user_google_email (str): The user's Google email address. Required.
33
+ max_results (Optional[int]): Maximum number of task lists to return (default: 1000, max: 1000).
34
+ page_token (Optional[str]): Token for pagination.
35
+
36
+ Returns:
37
+ str: List of task lists with their IDs, titles, and details.
38
+ """
39
+ logger.info(f"[list_task_lists] Invoked. Email: '{user_google_email}'")
40
+
41
+ try:
42
+ params = {}
43
+ if max_results is not None:
44
+ params["maxResults"] = max_results
45
+ if page_token:
46
+ params["pageToken"] = page_token
47
+
48
+ result = await asyncio.to_thread(
49
+ service.tasklists().list(**params).execute
50
+ )
51
+
52
+ task_lists = result.get("items", [])
53
+ next_page_token = result.get("nextPageToken")
54
+
55
+ if not task_lists:
56
+ return f"No task lists found for {user_google_email}."
57
+
58
+ response = f"Task Lists for {user_google_email}:\n"
59
+ for task_list in task_lists:
60
+ response += f"- {task_list['title']} (ID: {task_list['id']})\n"
61
+ response += f" Updated: {task_list.get('updated', 'N/A')}\n"
62
+
63
+ if next_page_token:
64
+ response += f"\nNext page token: {next_page_token}"
65
+
66
+ logger.info(f"Found {len(task_lists)} task lists for {user_google_email}")
67
+ return response
68
+
69
+ except HttpError as error:
70
+ message = f"API error: {error}. You might need to re-authenticate. LLM: Try 'start_google_auth' with the user's email ({user_google_email}) and service_name='Google Tasks'."
71
+ logger.error(message, exc_info=True)
72
+ raise Exception(message)
73
+ except Exception as e:
74
+ message = f"Unexpected error: {e}."
75
+ logger.exception(message)
76
+ raise Exception(message)
77
+
78
+
79
+ @server.tool()
80
+ @require_google_service("tasks", "tasks_read")
81
+ async def get_task_list(
82
+ service,
83
+ user_google_email: str,
84
+ task_list_id: str
85
+ ) -> str:
86
+ """
87
+ Get details of a specific task list.
88
+
89
+ Args:
90
+ user_google_email (str): The user's Google email address. Required.
91
+ task_list_id (str): The ID of the task list to retrieve.
92
+
93
+ Returns:
94
+ str: Task list details including title, ID, and last updated time.
95
+ """
96
+ logger.info(f"[get_task_list] Invoked. Email: '{user_google_email}', Task List ID: {task_list_id}")
97
+
98
+ try:
99
+ task_list = await asyncio.to_thread(
100
+ service.tasklists().get(tasklist=task_list_id).execute
101
+ )
102
+
103
+ response = f"""Task List Details for {user_google_email}:
104
+ - Title: {task_list['title']}
105
+ - ID: {task_list['id']}
106
+ - Updated: {task_list.get('updated', 'N/A')}
107
+ - Self Link: {task_list.get('selfLink', 'N/A')}"""
108
+
109
+ logger.info(f"Retrieved task list '{task_list['title']}' for {user_google_email}")
110
+ return response
111
+
112
+ except HttpError as error:
113
+ message = f"API error: {error}. You might need to re-authenticate. LLM: Try 'start_google_auth' with the user's email ({user_google_email}) and service_name='Google Tasks'."
114
+ logger.error(message, exc_info=True)
115
+ raise Exception(message)
116
+ except Exception as e:
117
+ message = f"Unexpected error: {e}."
118
+ logger.exception(message)
119
+ raise Exception(message)
120
+
121
+
122
+ @server.tool()
123
+ @require_google_service("tasks", "tasks")
124
+ async def create_task_list(
125
+ service,
126
+ user_google_email: str,
127
+ title: str
128
+ ) -> str:
129
+ """
130
+ Create a new task list.
131
+
132
+ Args:
133
+ user_google_email (str): The user's Google email address. Required.
134
+ title (str): The title of the new task list.
135
+
136
+ Returns:
137
+ str: Confirmation message with the new task list ID and details.
138
+ """
139
+ logger.info(f"[create_task_list] Invoked. Email: '{user_google_email}', Title: '{title}'")
140
+
141
+ try:
142
+ body = {
143
+ "title": title
144
+ }
145
+
146
+ result = await asyncio.to_thread(
147
+ service.tasklists().insert(body=body).execute
148
+ )
149
+
150
+ response = f"""Task List Created for {user_google_email}:
151
+ - Title: {result['title']}
152
+ - ID: {result['id']}
153
+ - Created: {result.get('updated', 'N/A')}
154
+ - Self Link: {result.get('selfLink', 'N/A')}"""
155
+
156
+ logger.info(f"Created task list '{title}' with ID {result['id']} for {user_google_email}")
157
+ return response
158
+
159
+ except HttpError as error:
160
+ message = f"API error: {error}. You might need to re-authenticate. LLM: Try 'start_google_auth' with the user's email ({user_google_email}) and service_name='Google Tasks'."
161
+ logger.error(message, exc_info=True)
162
+ raise Exception(message)
163
+ except Exception as e:
164
+ message = f"Unexpected error: {e}."
165
+ logger.exception(message)
166
+ raise Exception(message)
167
+
168
+
169
+ @server.tool()
170
+ @require_google_service("tasks", "tasks")
171
+ async def update_task_list(
172
+ service,
173
+ user_google_email: str,
174
+ task_list_id: str,
175
+ title: str
176
+ ) -> str:
177
+ """
178
+ Update an existing task list.
179
+
180
+ Args:
181
+ user_google_email (str): The user's Google email address. Required.
182
+ task_list_id (str): The ID of the task list to update.
183
+ title (str): The new title for the task list.
184
+
185
+ Returns:
186
+ str: Confirmation message with updated task list details.
187
+ """
188
+ logger.info(f"[update_task_list] Invoked. Email: '{user_google_email}', Task List ID: {task_list_id}, New Title: '{title}'")
189
+
190
+ try:
191
+ body = {
192
+ "id": task_list_id,
193
+ "title": title
194
+ }
195
+
196
+ result = await asyncio.to_thread(
197
+ service.tasklists().update(tasklist=task_list_id, body=body).execute
198
+ )
199
+
200
+ response = f"""Task List Updated for {user_google_email}:
201
+ - Title: {result['title']}
202
+ - ID: {result['id']}
203
+ - Updated: {result.get('updated', 'N/A')}"""
204
+
205
+ logger.info(f"Updated task list {task_list_id} with new title '{title}' for {user_google_email}")
206
+ return response
207
+
208
+ except HttpError as error:
209
+ message = f"API error: {error}. You might need to re-authenticate. LLM: Try 'start_google_auth' with the user's email ({user_google_email}) and service_name='Google Tasks'."
210
+ logger.error(message, exc_info=True)
211
+ raise Exception(message)
212
+ except Exception as e:
213
+ message = f"Unexpected error: {e}."
214
+ logger.exception(message)
215
+ raise Exception(message)
216
+
217
+
218
+ @server.tool()
219
+ @require_google_service("tasks", "tasks")
220
+ async def delete_task_list(
221
+ service,
222
+ user_google_email: str,
223
+ task_list_id: str
224
+ ) -> str:
225
+ """
226
+ Delete a task list. Note: This will also delete all tasks in the list.
227
+
228
+ Args:
229
+ user_google_email (str): The user's Google email address. Required.
230
+ task_list_id (str): The ID of the task list to delete.
231
+
232
+ Returns:
233
+ str: Confirmation message.
234
+ """
235
+ logger.info(f"[delete_task_list] Invoked. Email: '{user_google_email}', Task List ID: {task_list_id}")
236
+
237
+ try:
238
+ await asyncio.to_thread(
239
+ service.tasklists().delete(tasklist=task_list_id).execute
240
+ )
241
+
242
+ response = f"Task list {task_list_id} has been deleted for {user_google_email}. All tasks in this list have also been deleted."
243
+
244
+ logger.info(f"Deleted task list {task_list_id} for {user_google_email}")
245
+ return response
246
+
247
+ except HttpError as error:
248
+ message = f"API error: {error}. You might need to re-authenticate. LLM: Try 'start_google_auth' with the user's email ({user_google_email}) and service_name='Google Tasks'."
249
+ logger.error(message, exc_info=True)
250
+ raise Exception(message)
251
+ except Exception as e:
252
+ message = f"Unexpected error: {e}."
253
+ logger.exception(message)
254
+ raise Exception(message)
255
+
256
+
257
+ @server.tool()
258
+ @require_google_service("tasks", "tasks_read")
259
+ async def list_tasks(
260
+ service,
261
+ user_google_email: str,
262
+ task_list_id: str,
263
+ max_results: Optional[int] = None,
264
+ page_token: Optional[str] = None,
265
+ show_completed: Optional[bool] = None,
266
+ show_deleted: Optional[bool] = None,
267
+ show_hidden: Optional[bool] = None,
268
+ show_assigned: Optional[bool] = None,
269
+ completed_max: Optional[str] = None,
270
+ completed_min: Optional[str] = None,
271
+ due_max: Optional[str] = None,
272
+ due_min: Optional[str] = None,
273
+ updated_min: Optional[str] = None
274
+ ) -> str:
275
+ """
276
+ List all tasks in a specific task list.
277
+
278
+ Args:
279
+ user_google_email (str): The user's Google email address. Required.
280
+ task_list_id (str): The ID of the task list to retrieve tasks from.
281
+ max_results (Optional[int]): Maximum number of tasks to return (default: 20, max: 100).
282
+ page_token (Optional[str]): Token for pagination.
283
+ show_completed (Optional[bool]): Whether to include completed tasks (default: True).
284
+ show_deleted (Optional[bool]): Whether to include deleted tasks (default: False).
285
+ show_hidden (Optional[bool]): Whether to include hidden tasks (default: False).
286
+ show_assigned (Optional[bool]): Whether to include assigned tasks (default: False).
287
+ completed_max (Optional[str]): Upper bound for completion date (RFC 3339 timestamp).
288
+ completed_min (Optional[str]): Lower bound for completion date (RFC 3339 timestamp).
289
+ due_max (Optional[str]): Upper bound for due date (RFC 3339 timestamp).
290
+ due_min (Optional[str]): Lower bound for due date (RFC 3339 timestamp).
291
+ updated_min (Optional[str]): Lower bound for last modification time (RFC 3339 timestamp).
292
+
293
+ Returns:
294
+ str: List of tasks with their details.
295
+ """
296
+ logger.info(f"[list_tasks] Invoked. Email: '{user_google_email}', Task List ID: {task_list_id}")
297
+
298
+ try:
299
+ params = {"tasklist": task_list_id}
300
+ if max_results is not None:
301
+ params["maxResults"] = max_results
302
+ if page_token:
303
+ params["pageToken"] = page_token
304
+ if show_completed is not None:
305
+ params["showCompleted"] = show_completed
306
+ if show_deleted is not None:
307
+ params["showDeleted"] = show_deleted
308
+ if show_hidden is not None:
309
+ params["showHidden"] = show_hidden
310
+ if show_assigned is not None:
311
+ params["showAssigned"] = show_assigned
312
+ if completed_max:
313
+ params["completedMax"] = completed_max
314
+ if completed_min:
315
+ params["completedMin"] = completed_min
316
+ if due_max:
317
+ params["dueMax"] = due_max
318
+ if due_min:
319
+ params["dueMin"] = due_min
320
+ if updated_min:
321
+ params["updatedMin"] = updated_min
322
+
323
+ result = await asyncio.to_thread(
324
+ service.tasks().list(**params).execute
325
+ )
326
+
327
+ tasks = result.get("items", [])
328
+ next_page_token = result.get("nextPageToken")
329
+
330
+ if not tasks:
331
+ return f"No tasks found in task list {task_list_id} for {user_google_email}."
332
+
333
+ response = f"Tasks in list {task_list_id} for {user_google_email}:\n"
334
+ for task in tasks:
335
+ response += f"- {task.get('title', 'Untitled')} (ID: {task['id']})\n"
336
+ response += f" Status: {task.get('status', 'N/A')}\n"
337
+ if task.get('due'):
338
+ response += f" Due: {task['due']}\n"
339
+ if task.get('notes'):
340
+ response += f" Notes: {task['notes'][:100]}{'...' if len(task['notes']) > 100 else ''}\n"
341
+ if task.get('completed'):
342
+ response += f" Completed: {task['completed']}\n"
343
+ response += f" Updated: {task.get('updated', 'N/A')}\n"
344
+ response += "\n"
345
+
346
+ if next_page_token:
347
+ response += f"Next page token: {next_page_token}"
348
+
349
+ logger.info(f"Found {len(tasks)} tasks in list {task_list_id} for {user_google_email}")
350
+ return response
351
+
352
+ except HttpError as error:
353
+ message = f"API error: {error}. You might need to re-authenticate. LLM: Try 'start_google_auth' with the user's email ({user_google_email}) and service_name='Google Tasks'."
354
+ logger.error(message, exc_info=True)
355
+ raise Exception(message)
356
+ except Exception as e:
357
+ message = f"Unexpected error: {e}."
358
+ logger.exception(message)
359
+ raise Exception(message)
360
+
361
+
362
+ @server.tool()
363
+ @require_google_service("tasks", "tasks_read")
364
+ async def get_task(
365
+ service,
366
+ user_google_email: str,
367
+ task_list_id: str,
368
+ task_id: str
369
+ ) -> str:
370
+ """
371
+ Get details of a specific task.
372
+
373
+ Args:
374
+ user_google_email (str): The user's Google email address. Required.
375
+ task_list_id (str): The ID of the task list containing the task.
376
+ task_id (str): The ID of the task to retrieve.
377
+
378
+ Returns:
379
+ str: Task details including title, notes, status, due date, etc.
380
+ """
381
+ logger.info(f"[get_task] Invoked. Email: '{user_google_email}', Task List ID: {task_list_id}, Task ID: {task_id}")
382
+
383
+ try:
384
+ task = await asyncio.to_thread(
385
+ service.tasks().get(tasklist=task_list_id, task=task_id).execute
386
+ )
387
+
388
+ response = f"""Task Details for {user_google_email}:
389
+ - Title: {task.get('title', 'Untitled')}
390
+ - ID: {task['id']}
391
+ - Status: {task.get('status', 'N/A')}
392
+ - Updated: {task.get('updated', 'N/A')}"""
393
+
394
+ if task.get('due'):
395
+ response += f"\n- Due Date: {task['due']}"
396
+ if task.get('completed'):
397
+ response += f"\n- Completed: {task['completed']}"
398
+ if task.get('notes'):
399
+ response += f"\n- Notes: {task['notes']}"
400
+ if task.get('parent'):
401
+ response += f"\n- Parent Task ID: {task['parent']}"
402
+ if task.get('position'):
403
+ response += f"\n- Position: {task['position']}"
404
+ if task.get('selfLink'):
405
+ response += f"\n- Self Link: {task['selfLink']}"
406
+ if task.get('webViewLink'):
407
+ response += f"\n- Web View Link: {task['webViewLink']}"
408
+
409
+ logger.info(f"Retrieved task '{task.get('title', 'Untitled')}' for {user_google_email}")
410
+ return response
411
+
412
+ except HttpError as error:
413
+ message = f"API error: {error}. You might need to re-authenticate. LLM: Try 'start_google_auth' with the user's email ({user_google_email}) and service_name='Google Tasks'."
414
+ logger.error(message, exc_info=True)
415
+ raise Exception(message)
416
+ except Exception as e:
417
+ message = f"Unexpected error: {e}."
418
+ logger.exception(message)
419
+ raise Exception(message)
420
+
421
+
422
+ @server.tool()
423
+ @require_google_service("tasks", "tasks")
424
+ async def create_task(
425
+ service,
426
+ user_google_email: str,
427
+ task_list_id: str,
428
+ title: str,
429
+ notes: Optional[str] = None,
430
+ due: Optional[str] = None,
431
+ parent: Optional[str] = None,
432
+ previous: Optional[str] = None
433
+ ) -> str:
434
+ """
435
+ Create a new task in a task list.
436
+
437
+ Args:
438
+ user_google_email (str): The user's Google email address. Required.
439
+ task_list_id (str): The ID of the task list to create the task in.
440
+ title (str): The title of the task.
441
+ notes (Optional[str]): Notes/description for the task.
442
+ due (Optional[str]): Due date in RFC 3339 format (e.g., "2024-12-31T23:59:59Z").
443
+ parent (Optional[str]): Parent task ID (for subtasks).
444
+ previous (Optional[str]): Previous sibling task ID (for positioning).
445
+
446
+ Returns:
447
+ str: Confirmation message with the new task ID and details.
448
+ """
449
+ logger.info(f"[create_task] Invoked. Email: '{user_google_email}', Task List ID: {task_list_id}, Title: '{title}'")
450
+
451
+ try:
452
+ body = {
453
+ "title": title
454
+ }
455
+ if notes:
456
+ body["notes"] = notes
457
+ if due:
458
+ body["due"] = due
459
+
460
+ params = {"tasklist": task_list_id, "body": body}
461
+ if parent:
462
+ params["parent"] = parent
463
+ if previous:
464
+ params["previous"] = previous
465
+
466
+ result = await asyncio.to_thread(
467
+ service.tasks().insert(**params).execute
468
+ )
469
+
470
+ response = f"""Task Created for {user_google_email}:
471
+ - Title: {result['title']}
472
+ - ID: {result['id']}
473
+ - Status: {result.get('status', 'N/A')}
474
+ - Updated: {result.get('updated', 'N/A')}"""
475
+
476
+ if result.get('due'):
477
+ response += f"\n- Due Date: {result['due']}"
478
+ if result.get('notes'):
479
+ response += f"\n- Notes: {result['notes']}"
480
+ if result.get('webViewLink'):
481
+ response += f"\n- Web View Link: {result['webViewLink']}"
482
+
483
+ logger.info(f"Created task '{title}' with ID {result['id']} for {user_google_email}")
484
+ return response
485
+
486
+ except HttpError as error:
487
+ message = f"API error: {error}. You might need to re-authenticate. LLM: Try 'start_google_auth' with the user's email ({user_google_email}) and service_name='Google Tasks'."
488
+ logger.error(message, exc_info=True)
489
+ raise Exception(message)
490
+ except Exception as e:
491
+ message = f"Unexpected error: {e}."
492
+ logger.exception(message)
493
+ raise Exception(message)
494
+
495
+
496
+ @server.tool()
497
+ @require_google_service("tasks", "tasks")
498
+ async def update_task(
499
+ service,
500
+ user_google_email: str,
501
+ task_list_id: str,
502
+ task_id: str,
503
+ title: Optional[str] = None,
504
+ notes: Optional[str] = None,
505
+ status: Optional[str] = None,
506
+ due: Optional[str] = None
507
+ ) -> str:
508
+ """
509
+ Update an existing task.
510
+
511
+ Args:
512
+ user_google_email (str): The user's Google email address. Required.
513
+ task_list_id (str): The ID of the task list containing the task.
514
+ task_id (str): The ID of the task to update.
515
+ title (Optional[str]): New title for the task.
516
+ notes (Optional[str]): New notes/description for the task.
517
+ status (Optional[str]): New status ("needsAction" or "completed").
518
+ due (Optional[str]): New due date in RFC 3339 format.
519
+
520
+ Returns:
521
+ str: Confirmation message with updated task details.
522
+ """
523
+ logger.info(f"[update_task] Invoked. Email: '{user_google_email}', Task List ID: {task_list_id}, Task ID: {task_id}")
524
+
525
+ try:
526
+ # First get the current task to build the update body
527
+ current_task = await asyncio.to_thread(
528
+ service.tasks().get(tasklist=task_list_id, task=task_id).execute
529
+ )
530
+
531
+ body = {
532
+ "id": task_id,
533
+ "title": title if title is not None else current_task.get("title", ""),
534
+ "status": status if status is not None else current_task.get("status", "needsAction")
535
+ }
536
+
537
+ if notes is not None:
538
+ body["notes"] = notes
539
+ elif current_task.get("notes"):
540
+ body["notes"] = current_task["notes"]
541
+
542
+ if due is not None:
543
+ body["due"] = due
544
+ elif current_task.get("due"):
545
+ body["due"] = current_task["due"]
546
+
547
+ result = await asyncio.to_thread(
548
+ service.tasks().update(tasklist=task_list_id, task=task_id, body=body).execute
549
+ )
550
+
551
+ response = f"""Task Updated for {user_google_email}:
552
+ - Title: {result['title']}
553
+ - ID: {result['id']}
554
+ - Status: {result.get('status', 'N/A')}
555
+ - Updated: {result.get('updated', 'N/A')}"""
556
+
557
+ if result.get('due'):
558
+ response += f"\n- Due Date: {result['due']}"
559
+ if result.get('notes'):
560
+ response += f"\n- Notes: {result['notes']}"
561
+ if result.get('completed'):
562
+ response += f"\n- Completed: {result['completed']}"
563
+
564
+ logger.info(f"Updated task {task_id} for {user_google_email}")
565
+ return response
566
+
567
+ except HttpError as error:
568
+ message = f"API error: {error}. You might need to re-authenticate. LLM: Try 'start_google_auth' with the user's email ({user_google_email}) and service_name='Google Tasks'."
569
+ logger.error(message, exc_info=True)
570
+ raise Exception(message)
571
+ except Exception as e:
572
+ message = f"Unexpected error: {e}."
573
+ logger.exception(message)
574
+ raise Exception(message)
575
+
576
+
577
+ @server.tool()
578
+ @require_google_service("tasks", "tasks")
579
+ async def delete_task(
580
+ service,
581
+ user_google_email: str,
582
+ task_list_id: str,
583
+ task_id: str
584
+ ) -> str:
585
+ """
586
+ Delete a task from a task list.
587
+
588
+ Args:
589
+ user_google_email (str): The user's Google email address. Required.
590
+ task_list_id (str): The ID of the task list containing the task.
591
+ task_id (str): The ID of the task to delete.
592
+
593
+ Returns:
594
+ str: Confirmation message.
595
+ """
596
+ logger.info(f"[delete_task] Invoked. Email: '{user_google_email}', Task List ID: {task_list_id}, Task ID: {task_id}")
597
+
598
+ try:
599
+ await asyncio.to_thread(
600
+ service.tasks().delete(tasklist=task_list_id, task=task_id).execute
601
+ )
602
+
603
+ response = f"Task {task_id} has been deleted from task list {task_list_id} for {user_google_email}."
604
+
605
+ logger.info(f"Deleted task {task_id} for {user_google_email}")
606
+ return response
607
+
608
+ except HttpError as error:
609
+ message = f"API error: {error}. You might need to re-authenticate. LLM: Try 'start_google_auth' with the user's email ({user_google_email}) and service_name='Google Tasks'."
610
+ logger.error(message, exc_info=True)
611
+ raise Exception(message)
612
+ except Exception as e:
613
+ message = f"Unexpected error: {e}."
614
+ logger.exception(message)
615
+ raise Exception(message)
616
+
617
+
618
+ @server.tool()
619
+ @require_google_service("tasks", "tasks")
620
+ async def move_task(
621
+ service,
622
+ user_google_email: str,
623
+ task_list_id: str,
624
+ task_id: str,
625
+ parent: Optional[str] = None,
626
+ previous: Optional[str] = None,
627
+ destination_task_list: Optional[str] = None
628
+ ) -> str:
629
+ """
630
+ Move a task to a different position or parent within the same list, or to a different list.
631
+
632
+ Args:
633
+ user_google_email (str): The user's Google email address. Required.
634
+ task_list_id (str): The ID of the current task list containing the task.
635
+ task_id (str): The ID of the task to move.
636
+ parent (Optional[str]): New parent task ID (for making it a subtask).
637
+ previous (Optional[str]): Previous sibling task ID (for positioning).
638
+ destination_task_list (Optional[str]): Destination task list ID (for moving between lists).
639
+
640
+ Returns:
641
+ str: Confirmation message with updated task details.
642
+ """
643
+ logger.info(f"[move_task] Invoked. Email: '{user_google_email}', Task List ID: {task_list_id}, Task ID: {task_id}")
644
+
645
+ try:
646
+ params = {
647
+ "tasklist": task_list_id,
648
+ "task": task_id
649
+ }
650
+ if parent:
651
+ params["parent"] = parent
652
+ if previous:
653
+ params["previous"] = previous
654
+ if destination_task_list:
655
+ params["destinationTasklist"] = destination_task_list
656
+
657
+ result = await asyncio.to_thread(
658
+ service.tasks().move(**params).execute
659
+ )
660
+
661
+ response = f"""Task Moved for {user_google_email}:
662
+ - Title: {result['title']}
663
+ - ID: {result['id']}
664
+ - Status: {result.get('status', 'N/A')}
665
+ - Updated: {result.get('updated', 'N/A')}"""
666
+
667
+ if result.get('parent'):
668
+ response += f"\n- Parent Task ID: {result['parent']}"
669
+ if result.get('position'):
670
+ response += f"\n- Position: {result['position']}"
671
+
672
+ move_details = []
673
+ if destination_task_list:
674
+ move_details.append(f"moved to task list {destination_task_list}")
675
+ if parent:
676
+ move_details.append(f"made a subtask of {parent}")
677
+ if previous:
678
+ move_details.append(f"positioned after {previous}")
679
+
680
+ if move_details:
681
+ response += f"\n- Move Details: {', '.join(move_details)}"
682
+
683
+ logger.info(f"Moved task {task_id} for {user_google_email}")
684
+ return response
685
+
686
+ except HttpError as error:
687
+ message = f"API error: {error}. You might need to re-authenticate. LLM: Try 'start_google_auth' with the user's email ({user_google_email}) and service_name='Google Tasks'."
688
+ logger.error(message, exc_info=True)
689
+ raise Exception(message)
690
+ except Exception as e:
691
+ message = f"Unexpected error: {e}."
692
+ logger.exception(message)
693
+ raise Exception(message)
694
+
695
+
696
+ @server.tool()
697
+ @require_google_service("tasks", "tasks")
698
+ async def clear_completed_tasks(
699
+ service,
700
+ user_google_email: str,
701
+ task_list_id: str
702
+ ) -> str:
703
+ """
704
+ Clear all completed tasks from a task list. The tasks will be marked as hidden.
705
+
706
+ Args:
707
+ user_google_email (str): The user's Google email address. Required.
708
+ task_list_id (str): The ID of the task list to clear completed tasks from.
709
+
710
+ Returns:
711
+ str: Confirmation message.
712
+ """
713
+ logger.info(f"[clear_completed_tasks] Invoked. Email: '{user_google_email}', Task List ID: {task_list_id}")
714
+
715
+ try:
716
+ await asyncio.to_thread(
717
+ service.tasks().clear(tasklist=task_list_id).execute
718
+ )
719
+
720
+ response = f"All completed tasks have been cleared from task list {task_list_id} for {user_google_email}. The tasks are now hidden and won't appear in default task list views."
721
+
722
+ logger.info(f"Cleared completed tasks from list {task_list_id} for {user_google_email}")
723
+ return response
724
+
725
+ except HttpError as error:
726
+ message = f"API error: {error}. You might need to re-authenticate. LLM: Try 'start_google_auth' with the user's email ({user_google_email}) and service_name='Google Tasks'."
727
+ logger.error(message, exc_info=True)
728
+ raise Exception(message)
729
+ except Exception as e:
730
+ message = f"Unexpected error: {e}."
731
+ logger.exception(message)
732
+ raise Exception(message)
main.py CHANGED
@@ -40,7 +40,7 @@ def safe_print(text):
40
40
  # Running as MCP server, suppress output to avoid JSON parsing errors
41
41
  logger.debug(f"[MCP Server] {text}")
42
42
  return
43
-
43
+
44
44
  try:
45
45
  print(text, file=sys.stderr)
46
46
  except UnicodeEncodeError:
@@ -56,7 +56,7 @@ def main():
56
56
  parser.add_argument('--single-user', action='store_true',
57
57
  help='Run in single-user mode - bypass session mapping and use any credentials from the credentials directory')
58
58
  parser.add_argument('--tools', nargs='*',
59
- choices=['gmail', 'drive', 'calendar', 'docs', 'sheets', 'chat', 'forms', 'slides'],
59
+ choices=['gmail', 'drive', 'calendar', 'docs', 'sheets', 'chat', 'forms', 'slides', 'tasks'],
60
60
  help='Specify which tools to register. If not provided, all tools are registered.')
61
61
  parser.add_argument('--transport', choices=['stdio', 'streamable-http'], default='stdio',
62
62
  help='Transport mode: stdio (default) or streamable-http')
@@ -91,7 +91,8 @@ def main():
91
91
  'sheets': lambda: __import__('gsheets.sheets_tools'),
92
92
  'chat': lambda: __import__('gchat.chat_tools'),
93
93
  'forms': lambda: __import__('gforms.forms_tools'),
94
- 'slides': lambda: __import__('gslides.slides_tools')
94
+ 'slides': lambda: __import__('gslides.slides_tools'),
95
+ 'tasks': lambda: __import__('gtasks.tasks_tools')
95
96
  }
96
97
 
97
98
  tool_icons = {
@@ -102,7 +103,8 @@ def main():
102
103
  'sheets': '📊',
103
104
  'chat': '💬',
104
105
  'forms': '📝',
105
- 'slides': '🖼️'
106
+ 'slides': '🖼️',
107
+ 'tasks': '✓'
106
108
  }
107
109
 
108
110
  # Import specified tools or all tools if none specified
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: workspace-mcp
3
- Version: 1.1.3
3
+ Version: 1.1.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
@@ -53,7 +53,9 @@ Dynamic: license-file
53
53
 
54
54
  **This is the single most feature-complete Google Workspace MCP server**
55
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*
56
+ *Full natural language control over Google Calendar, Drive, Gmail, Docs, Sheets, Slides, Forms, Tasks, and Chat through all MCP clients, AI assistants and developer tools.*
57
+
58
+ ###### Support for all free Google accounts (Gmail, Docs, Drive etc) & Google Workspace plans (Starter, Standard, Plus, Enterprise, Non Profit etc) with their expanded app options like Chat & Spaces.
57
59
 
58
60
  </div>
59
61
 
@@ -85,11 +87,11 @@ Dynamic: license-file
85
87
  > In this case, Sonnet 4 took a pass & a human (me) verified them 6/28/25.
86
88
 
87
89
 
88
- ## 🌐 Overview
90
+ ## Overview
89
91
 
90
92
  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.
91
93
 
92
- ## Features
94
+ ## Features
93
95
 
94
96
  - **🔐 Advanced OAuth 2.0**: Secure authentication with automatic token refresh, transport-aware callback handling, session management, and centralized scope management
95
97
  - **📅 Google Calendar**: Full calendar management with event CRUD operations
@@ -99,6 +101,7 @@ A production-ready MCP server that integrates all major Google Workspace service
99
101
  - **📊 Google Sheets**: Comprehensive spreadsheet management with flexible cell operations and comment management
100
102
  - **🖼️ Google Slides**: Presentation management with slide creation, updates, content manipulation, and comment management
101
103
  - **📝 Google Forms**: Form creation, retrieval, publish settings, and response management
104
+ - **✓ Google Tasks**: Complete task and task list management with hierarchy, due dates, and status tracking
102
105
  - **💬 Google Chat**: Space management and messaging capabilities
103
106
  - **🔄 Multiple Transports**: HTTP with SSE fallback, OpenAPI compatibility via `mcpo`
104
107
  - **⚡ High Performance**: Service caching, thread-safe sessions, FastMCP integration
@@ -121,7 +124,7 @@ export GOOGLE_OAUTH_CLIENT_SECRET="your-client-secret"
121
124
  uvx workspace-mcp
122
125
 
123
126
  # Start with specific tools only
124
- uvx workspace-mcp --tools gmail drive calendar
127
+ uvx workspace-mcp --tools gmail drive calendar tasks
125
128
 
126
129
  # Start in HTTP mode for debugging
127
130
  uvx workspace-mcp --transport streamable-http
@@ -149,7 +152,7 @@ uv run main.py
149
152
 
150
153
  1. **Google Cloud Setup**:
151
154
  - Create OAuth 2.0 credentials (web application) in [Google Cloud Console](https://console.cloud.google.com/)
152
- - Enable APIs: Calendar, Drive, Gmail, Docs, Sheets, Slides, Forms, Chat
155
+ - Enable APIs: Calendar, Drive, Gmail, Docs, Sheets, Slides, Forms, Tasks, Chat
153
156
  - Add redirect URI: `http://localhost:8000/oauth2callback`
154
157
  - Configure credentials using one of these methods:
155
158
 
@@ -201,7 +204,7 @@ uv run main.py --transport streamable-http
201
204
  uv run main.py --single-user
202
205
 
203
206
  # Selective tool registration (only register specific tools)
204
- uv run main.py --tools gmail drive calendar
207
+ uv run main.py --tools gmail drive calendar tasks
205
208
  uv run main.py --tools sheets docs
206
209
  uv run main.py --single-user --tools gmail # Can combine with other flags
207
210
 
@@ -210,7 +213,7 @@ docker build -t workspace-mcp .
210
213
  docker run -p 8000:8000 -v $(pwd):/app workspace-mcp --transport streamable-http
211
214
  ```
212
215
 
213
- **Available Tools for `--tools` flag**: `gmail`, `drive`, `calendar`, `docs`, `sheets`, `forms`, `chat`
216
+ **Available Tools for `--tools` flag**: `gmail`, `drive`, `calendar`, `docs`, `sheets`, `forms`, `tasks`, `chat`
214
217
 
215
218
  ### Connect to Claude Desktop
216
219
 
@@ -254,7 +257,7 @@ After running the script, just restart Claude Desktop and you're ready to go.
254
257
 
255
258
  **Get Google OAuth Credentials** (if you don't have them):
256
259
  - Go to [Google Cloud Console](https://console.cloud.google.com/)
257
- - Create a new project and enable APIs: Calendar, Drive, Gmail, Docs, Sheets, Slides, Forms, Chat
260
+ - Create a new project and enable APIs: Calendar, Drive, Gmail, Docs, Sheets, Slides, Forms, Tasks, Chat
258
261
  - Create OAuth 2.0 Client ID (Web application) with redirect URI: `http://localhost:8000/oauth2callback`
259
262
 
260
263
  **Development Installation (For Contributors)**:
@@ -392,6 +395,23 @@ When calling a tool:
392
395
  | `get_form_response` | Get individual form response details |
393
396
  | `list_form_responses` | List all responses to a form with pagination |
394
397
 
398
+ ### ✓ Google Tasks ([`tasks_tools.py`](gtasks/tasks_tools.py))
399
+
400
+ | Tool | Description |
401
+ |------|-------------|
402
+ | `list_task_lists` | List all task lists with pagination support |
403
+ | `get_task_list` | Retrieve details of a specific task list |
404
+ | `create_task_list` | Create new task lists with custom titles |
405
+ | `update_task_list` | Modify existing task list titles |
406
+ | `delete_task_list` | Remove task lists and all contained tasks |
407
+ | `list_tasks` | List tasks in a specific list with filtering options |
408
+ | `get_task` | Retrieve detailed information about a specific task |
409
+ | `create_task` | Create new tasks with title, notes, due dates, and hierarchy |
410
+ | `update_task` | Modify task properties including title, notes, status, and due dates |
411
+ | `delete_task` | Remove tasks from task lists |
412
+ | `move_task` | Reposition tasks within lists or move between lists |
413
+ | `clear_completed_tasks` | Hide all completed tasks from a list |
414
+
395
415
  ### 💬 Google Chat ([`chat_tools.py`](gchat/chat_tools.py))
396
416
 
397
417
  | Tool | Description |
@@ -1,14 +1,14 @@
1
- main.py,sha256=2WLURMeCnoVws_OJOj2dm6yz7cegYJl5FqzYBFa2YOI,7513
1
+ main.py,sha256=a4w_AcD_nSJo9697-75tZ3sU0tqOP1J8xTrXXD7qmns,7601
2
2
  auth/__init__.py,sha256=gPCU3GE-SLy91S3D3CbX-XfKBm6hteK_VSPKx7yjT5s,42
3
3
  auth/google_auth.py,sha256=JiGrHFpzhuxQgUNumZtAbyl8HTisDVdnvVFeSqpkCfg,32939
4
4
  auth/oauth_callback_server.py,sha256=igrur3fkZSY0bawufrH4AN9fMNpobUdAUp1BG7AQC6w,9341
5
5
  auth/oauth_responses.py,sha256=qbirSB4d7mBRKcJKqGLrJxRAPaLHqObf9t-VMAq6UKA,7020
6
- auth/scopes.py,sha256=kMRdFN0wLyipFkp7IitTHs-M6zhZD-oieVd7fylueBc,3320
7
- auth/service_decorator.py,sha256=h9bkG1O6U-p4_yT1KseBKJvueprKd4SVJe1Bj2VrdXA,15669
6
+ auth/scopes.py,sha256=v091tidkMnhB0pPWOr0O08mU_s9yxSwVZkpVOyvlSwY,3550
7
+ auth/service_decorator.py,sha256=8UfJnST6oi5Mci2YUdiIocn8--0oAEXm74VrGMroqzQ,15846
8
8
  core/__init__.py,sha256=AHVKdPl6v4lUFm2R-KuGuAgEmCyfxseMeLGtntMcqCs,43
9
9
  core/comments.py,sha256=vVfZYjH0kwqFyXcwvBx3m0Ko4WmfTJTkfD3dCQbucuc,11215
10
10
  core/context.py,sha256=zNgPXf9EO2EMs9sQkfKiywoy6sEOksVNgOrJMA_c30Y,768
11
- core/server.py,sha256=8A5_o6RCZ3hhsAiCszZhHiUJbVVrxJLspcvCiMmt27Q,9265
11
+ core/server.py,sha256=KNAo43WTgzb6WSOyYE4Nixs5yLSg3NGqT6V2v3h3Wxo,9326
12
12
  core/utils.py,sha256=sUNPhM0xh3tqgyCZxTcoje37Et-pbNJTksybTatDyho,10127
13
13
  gcalendar/__init__.py,sha256=D5fSdAwbeomoaj7XAdxSnIy-NVKNkpExs67175bOtfc,46
14
14
  gcalendar/calendar_tools.py,sha256=SIiSJRxG3G9KsScow0pYwew600_PdtFqlOo-y2vXQRo,22144
@@ -26,9 +26,11 @@ gsheets/__init__.py,sha256=jFfhD52w_EOVw6N5guf_dIc9eP2khW_eS9UAPJg_K3k,446
26
26
  gsheets/sheets_tools.py,sha256=TVlJ-jcIvJ_sJt8xO4-sBWIshb8rabJhjTmZfzHIJsU,11898
27
27
  gslides/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
28
  gslides/slides_tools.py,sha256=wil3XRyUMzUbpBUMqis0CW5eRuwOrP0Lp7-6WbF4QVU,10117
29
- workspace_mcp-1.1.3.dist-info/licenses/LICENSE,sha256=bB8L7rIyRy5o-WHxGgvRuY8hUTzNu4h3DTkvyV8XFJo,1070
30
- workspace_mcp-1.1.3.dist-info/METADATA,sha256=Gi0UFOQxhtECNLOLcB3JufzpfKV3LPuB1rd3Bz016aE,20158
31
- workspace_mcp-1.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
32
- workspace_mcp-1.1.3.dist-info/entry_points.txt,sha256=kPiEfOTuf-ptDM0Rf2OlyrFudGW7hCZGg4MCn2Foxs4,44
33
- workspace_mcp-1.1.3.dist-info/top_level.txt,sha256=Y8mAkTitLNE2zZEJ-DbqR9R7Cs1V1MMf-UploVdOvlw,73
34
- workspace_mcp-1.1.3.dist-info/RECORD,,
29
+ gtasks/__init__.py,sha256=qwOWUzQbkYLSBrdhCqEkAWPH2lEOljk1mLtrlab9YZc,107
30
+ gtasks/tasks_tools.py,sha256=Gy_j1VTeaa4HD2HQe0U1QjG3dQrkijtPNe0dUq5mAZQ,26021
31
+ workspace_mcp-1.1.4.dist-info/licenses/LICENSE,sha256=bB8L7rIyRy5o-WHxGgvRuY8hUTzNu4h3DTkvyV8XFJo,1070
32
+ workspace_mcp-1.1.4.dist-info/METADATA,sha256=9e72G7CXNSO56YIRgxtGYHW1gEttRlOMKVGjuPlkxvc,21435
33
+ workspace_mcp-1.1.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
34
+ workspace_mcp-1.1.4.dist-info/entry_points.txt,sha256=kPiEfOTuf-ptDM0Rf2OlyrFudGW7hCZGg4MCn2Foxs4,44
35
+ workspace_mcp-1.1.4.dist-info/top_level.txt,sha256=uAg7uV2mETWYRw5g80XtO1lhxVO1sY6_IihNdG_4n24,80
36
+ workspace_mcp-1.1.4.dist-info/RECORD,,
@@ -8,4 +8,5 @@ gforms
8
8
  gmail
9
9
  gsheets
10
10
  gslides
11
+ gtasks
11
12
  main