Skip to main content
Glama
Johnxjp

Todoist Python MCP Server

by Johnxjp

create_task

Add new tasks to Todoist with content, due dates, priorities, labels, and project assignments for task management.

Instructions

Create a new task

Args:
- content [str]: Task content. This value may contain markdown-formatted text and hyperlinks. Details on markdown support can be found in the Text Formatting article in the Help Center.
- description [str]: A description for the task. This value may contain markdown-formatted text and hyperlinks. Details on markdown support can be found in the Text Formatting article in the Help Center.
- project_id [str]: The ID of the project to add the task. If none, adds to user's inbox by default.
- labels [list[str]]: The task's labels (a list of names that may represent either personal or shared labels).
- priority [int]: Task priority from 1 (normal) to 4 (urgent).
- due_date [str]: Specific date in YYYY-MM-DD format relative to user’s timezone.
- section_id [str]: The ID of the section to add the task to

Returns:
- task_id: str:

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYes
descriptionNo
project_idNo
labelsNo
priorityNo
due_dateNo
section_idNo

Implementation Reference

  • The main handler function for the 'create_task' tool, decorated with @mcp.tool() which also handles registration. It creates a new task in Todoist using the todoist_api.add_task method, constructing parameters from inputs, and returns the new task ID.
    @mcp.tool()
    def create_task(
        content: str,
        description: Optional[str] = None,
        project_id: Optional[str] = None,
        labels: Optional[list[str]] = None,
        priority: Optional[int] = None,
        due_date: Optional[str] = None,
        section_id: Optional[str] = None,
    ) -> str:
        """
        Create a new task
    
        Args:
        - content [str]: Task content. This value may contain markdown-formatted text and hyperlinks. Details on markdown support can be found in the Text Formatting article in the Help Center.
        - description [str]: A description for the task. This value may contain markdown-formatted text and hyperlinks. Details on markdown support can be found in the Text Formatting article in the Help Center.
        - project_id [str]: The ID of the project to add the task. If none, adds to user's inbox by default.
        - labels [list[str]]: The task's labels (a list of names that may represent either personal or shared labels).
        - priority [int]: Task priority from 1 (normal) to 4 (urgent).
        - due_date [str]: Specific date in YYYY-MM-DD format relative to user’s timezone.
        - section_id [str]: The ID of the section to add the task to
    
        Returns:
        - task_id: str:
        """
        try:
            data = {}
            if description:
                data["description"] = description
            if project_id:
                data["project_id"] = project_id
            if labels:
                if isinstance(labels, str):
                    labels = [labels]
                data["labels"] = labels
            if priority:
                data["priority"] = priority
            if due_date:
                data["due_date"] = due_date
            if section_id:
                data["section_id"] = section_id
    
            task = todoist_api.add_task(content, **data)
            return task.id
        except Exception as e:
            raise Exception(f"Couldn't create task {str(e)}")

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/Johnxjp/todoist-mcp-python'

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