clear_completed_tasks
Remove completed tasks from a Google Workspace task list. This tool marks completed tasks as hidden, helping users maintain a clean and organized task list.
Instructions
Clear all completed tasks from a task list. The tasks will be marked as hidden.
Args: user_google_email (str): The user's Google email address. Required. task_list_id (str): The ID of the task list to clear completed tasks from.
Returns: str: Confirmation message.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| task_list_id | Yes | ||
| user_google_email | Yes |
Implementation Reference
- gtasks/tasks_tools.py:858-895 (handler)The handler function for the 'clear_completed_tasks' tool. It is registered via @server.tool(), requires Google Tasks authentication, handles errors, logs the action, calls the Google Tasks API to clear (hide) all completed tasks in the specified task list, and returns a confirmation message.@server.tool() # type: ignore @require_google_service("tasks", "tasks") # type: ignore @handle_http_errors("clear_completed_tasks", service_type="tasks") # type: ignore async def clear_completed_tasks( service: Resource, user_google_email: str, task_list_id: str ) -> str: """ Clear all completed tasks from a task list. The tasks will be marked as hidden. Args: user_google_email (str): The user's Google email address. Required. task_list_id (str): The ID of the task list to clear completed tasks from. Returns: str: Confirmation message. """ logger.info(f"[clear_completed_tasks] Invoked. Email: '{user_google_email}', Task List ID: {task_list_id}") try: await asyncio.to_thread( service.tasks().clear(tasklist=task_list_id).execute ) 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." logger.info(f"Cleared completed tasks from list {task_list_id} for {user_google_email}") return response except HttpError as error: 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'." logger.error(message, exc_info=True) raise Exception(message) except Exception as e: message = f"Unexpected error: {e}." logger.exception(message) raise Exception(message)
- gtasks/tasks_tools.py:858-858 (registration)The @server.tool() decorator registers the clear_completed_tasks function as an MCP tool.@server.tool() # type: ignore