Skip to main content
Glama
ZatesloFL

Google Workspace MCP Server

by ZatesloFL

create_task

Add a new task to a Google Workspace task list using a user’s email, task list ID, and optional details like title, notes, due date, parent task, and sibling position.

Instructions

Create a new task in a task list.

Args: user_google_email (str): The user's Google email address. Required. task_list_id (str): The ID of the task list to create the task in. title (str): The title of the task. notes (Optional[str]): Notes/description for the task. due (Optional[str]): Due date in RFC 3339 format (e.g., "2024-12-31T23:59:59Z"). parent (Optional[str]): Parent task ID (for subtasks). previous (Optional[str]): Previous sibling task ID (for positioning).

Returns: str: Confirmation message with the new task ID and details.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dueNo
notesNo
parentNo
previousNo
task_list_idYes
titleYes
user_google_emailYes

Implementation Reference

  • The handler function for the 'create_task' tool. It is registered via the @server.tool() decorator, requires Google Tasks service authentication, handles HTTP errors, and creates a new task in the specified task list using the Google Tasks API's tasks.insert method. Includes input parameters for title, notes, due date, parent, and previous sibling for positioning.
    @server.tool()  # type: ignore
    @require_google_service("tasks", "tasks")  # type: ignore
    @handle_http_errors("create_task", service_type="tasks")  # type: ignore
    async def create_task(
        service: Resource,
        user_google_email: str,
        task_list_id: str,
        title: str,
        notes: Optional[str] = None,
        due: Optional[str] = None,
        parent: Optional[str] = None,
        previous: Optional[str] = None
    ) -> str:
        """
        Create a new task in a task list.
    
        Args:
            user_google_email (str): The user's Google email address. Required.
            task_list_id (str): The ID of the task list to create the task in.
            title (str): The title of the task.
            notes (Optional[str]): Notes/description for the task.
            due (Optional[str]): Due date in RFC 3339 format (e.g., "2024-12-31T23:59:59Z").
            parent (Optional[str]): Parent task ID (for subtasks).
            previous (Optional[str]): Previous sibling task ID (for positioning).
    
        Returns:
            str: Confirmation message with the new task ID and details.
        """
        logger.info(f"[create_task] Invoked. Email: '{user_google_email}', Task List ID: {task_list_id}, Title: '{title}'")
    
        try:
            body = {
                "title": title
            }
            if notes:
                body["notes"] = notes
            if due:
                body["due"] = due
    
            params = {"tasklist": task_list_id, "body": body}
            if parent:
                params["parent"] = parent
            if previous:
                params["previous"] = previous
    
            result = await asyncio.to_thread(
                service.tasks().insert(**params).execute
            )
    
            response = f"""Task Created for {user_google_email}:
    - Title: {result['title']}
    - ID: {result['id']}
    - Status: {result.get('status', 'N/A')}
    - Updated: {result.get('updated', 'N/A')}"""
    
            if result.get('due'):
                response += f"\n- Due Date: {result['due']}"
            if result.get('notes'):
                response += f"\n- Notes: {result['notes']}"
            if result.get('webViewLink'):
                response += f"\n- Web View Link: {result['webViewLink']}"
    
            logger.info(f"Created task '{title}' with ID {result['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)
  • The @server.tool() decorator registers the create_task function as an MCP tool.
    @server.tool()  # type: ignore
Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ZatesloFL/google_workspace_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server