Skip to main content
Glama
Johnxjp

Todoist Python MCP Server

by Johnxjp

get_tasks

Fetch tasks from Todoist with filters for project, labels, priority, due date, or overdue status to organize and manage your to-do list.

Instructions

Fetch user's tasks. These can be filtered by project, labels, time, etc. If no filters are provided, all tasks are returned.

Args:
- project_id: The string ID of the project to fetch tasks from. Example '1234567890'
- project_name: Name of the project to fetch tasks from. Example 'Work' or 'Inbox'
- task_name: Filter tasks by name. Example 'Buy groceries'
- labels: List of tags used to filter tasks.
- priority: Filter tasks by priority level. 4 (urgent), 3 (high), 2 (normal), 1 (low)
- due_date: Specific due date in YYYY-MM-DD format. Example '2021-12-31'
- is_overdue: Filter tasks that are overdue.
- limit: Maximum number of tasks to return. Default is all.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idNo
project_nameNo
task_nameNo
labelsNo
due_dateNo
is_overdueNo
priorityNo
limitNo

Implementation Reference

  • The handler function decorated with @mcp.tool(), which registers and implements the get_tasks tool. Fetches tasks from Todoist API and applies filters based on project, name, labels, due date, overdue status, priority, and limit.
    @mcp.tool()
    def get_tasks(
        project_id: Optional[str] = None,
        project_name: Optional[str] = None,
        task_name: Optional[str] = None,
        labels: Optional[list[str]] = None,
        due_date: Optional[str] = None,
        is_overdue: Optional[bool] = None,
        priority: Optional[Literal[1, 2, 3, 4]] = None,
        limit: Optional[int] = None,
    ) -> list[str]:
        """
        Fetch user's tasks. These can be filtered by project, labels, time, etc. If no filters are provided, all tasks are returned.
    
        Args:
        - project_id: The string ID of the project to fetch tasks from. Example '1234567890'
        - project_name: Name of the project to fetch tasks from. Example 'Work' or 'Inbox'
        - task_name: Filter tasks by name. Example 'Buy groceries'
        - labels: List of tags used to filter tasks.
        - priority: Filter tasks by priority level. 4 (urgent), 3 (high), 2 (normal), 1 (low)
        - due_date: Specific due date in YYYY-MM-DD format. Example '2021-12-31'
        - is_overdue: Filter tasks that are overdue.
        - limit: Maximum number of tasks to return. Default is all.
        """
        tasks = todoist_api.get_tasks()
    
        # How to implement "did you mean this project?" feature?
        if project_name:
            project_id = get_project_id_by_name(project_name)
            if not project_id:
                raise ValueError(f"Project '{project_name}' not found")
    
        if project_id:
            project_id = project_id.strip('"')
            tasks = [t for t in tasks if t.project_id == project_id]
    
        if task_name:
            tasks = [t for t in tasks if task_name.lower() in t.content.lower()]
    
        if due_date:
            tasks = [t for t in tasks if t.due and t.due["date"] == due_date]
    
        if is_overdue is not None:
            now = datetime.today().strftime("%Y-%m-%d")
            tasks = [
                t for t in tasks if t.due and (date_difference(now, t.due["date"]) < 0) == is_overdue
            ]
    
        if labels:
            for label in labels:
                tasks = [t for t in tasks if label.lower() in [l.lower() for l in t.labels]]
    
        if priority:
            tasks = [t for t in tasks if t.priority == priority]
    
        return [
            {
                "id": t.id,
                "title": t.content,
                "priority": t.priority,
                "due": t.due["date"] if t.due else None,
            }
            for t in tasks
        ][:limit]
  • The @mcp.tool() decorator registers the get_tasks function as an MCP tool.
    @mcp.tool()
  • Function signature with type annotations and detailed docstring defining the input schema and parameters for the get_tasks tool.
    def get_tasks(
        project_id: Optional[str] = None,
        project_name: Optional[str] = None,
        task_name: Optional[str] = None,
        labels: Optional[list[str]] = None,
        due_date: Optional[str] = None,
        is_overdue: Optional[bool] = None,
        priority: Optional[Literal[1, 2, 3, 4]] = None,
        limit: Optional[int] = None,
    ) -> list[str]:
        """
        Fetch user's tasks. These can be filtered by project, labels, time, etc. If no filters are provided, all tasks are returned.
    
        Args:
        - project_id: The string ID of the project to fetch tasks from. Example '1234567890'
        - project_name: Name of the project to fetch tasks from. Example 'Work' or 'Inbox'
        - task_name: Filter tasks by name. Example 'Buy groceries'
        - labels: List of tags used to filter tasks.
        - priority: Filter tasks by priority level. 4 (urgent), 3 (high), 2 (normal), 1 (low)
        - due_date: Specific due date in YYYY-MM-DD format. Example '2021-12-31'
        - is_overdue: Filter tasks that are overdue.
        - limit: Maximum number of tasks to return. Default is all.
        """
  • Helper function used by get_tasks to resolve project_name to project_id.
    def get_project_id_by_name(project_name: str) -> str:
        """Search for a project by name and return its ID"""
        projects = get_projects()
        for project in projects:
            if project.name.lower() == project_name.lower():
                return project.id
        return None
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but offers limited behavioral insight. It mentions the tool fetches tasks and describes filtering logic, but doesn't disclose critical traits like authentication needs, rate limits, pagination behavior, error handling, or whether it's read-only (implied but not stated). The description doesn't contradict annotations, but fails to compensate for their absence.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with a concise opening sentence followed by a detailed parameter list. Every sentence adds value, and it's appropriately sized for an 8-parameter tool. Minor room for improvement in front-loading key behavioral details, but overall efficient and clear.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (8 parameters, no annotations, no output schema), the description is partially complete. It excels in parameter documentation but lacks output format details, error conditions, and behavioral context. For a read operation with many filters, more guidance on result structure and limitations would enhance completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds substantial meaning beyond the input schema, which has 0% description coverage. It provides clear explanations for all 8 parameters, including examples (e.g., 'Example '1234567890''), format specifications ('YYYY-MM-DD format'), enumerated values ('4 (urgent), 3 (high)...'), and default behavior ('Default is all'). This fully compensates for the schema's lack of descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with 'Fetch user's tasks' (verb+resource). It distinguishes from siblings like create_task or delete_task by being a read operation, though it doesn't explicitly contrast with get_projects. The filtering scope is well-defined, making the purpose specific and actionable.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage through the filtering context ('filtered by project, labels, time, etc.') and notes that 'If no filters are provided, all tasks are returned.' However, it lacks explicit guidance on when to use this tool versus alternatives like get_projects or search-oriented siblings, and doesn't mention prerequisites or error conditions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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

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