create_task
Add a new task to Todoist with customizable details including content, description, project ID, labels, priority, due date, and section ID for efficient 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
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | ||
| description | No | ||
| due_date | No | ||
| labels | No | ||
| priority | No | ||
| project_id | No | ||
| section_id | No |
Implementation Reference
- todoist_server.py:137-183 (handler)The `create_task` function is the main handler for the MCP tool. It is decorated with `@mcp.tool()` which registers it as a tool. The function signature defines the input schema (parameters like content, project_id, etc.), and the docstring provides detailed descriptions. The body constructs a data dict from optional params and calls `todoist_api.add_task` to create the task, returning 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)}")
- todoist_server.py:138-146 (schema)The function signature provides the input schema for the `create_task` tool, specifying required (content) and optional parameters with types.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:
- todoist_server.py:137-137 (registration)The `@mcp.tool()` decorator registers the `create_task` function as an MCP tool.@mcp.tool()