Skip to main content
Glama

get_tasks

Retrieve Todoist tasks with filtering options by project, section, label, or natural language queries like 'today' or 'overdue'.

Instructions

Get tasks from Todoist with optional filtering.

Args: project_id: Filter tasks by project ID section_id: Filter tasks by section ID label: Filter tasks by label filter_query: Natural language filter (e.g., 'today', 'overdue', 'p1')

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idNo
section_idNo
labelNo
filter_queryNo

Implementation Reference

  • MCP tool handler implementation for 'get_tasks'. Uses @mcp.tool() decorator for registration and handles filtering, fetching via TodoistClient, and formatting output as a string list.
    @mcp.tool() async def get_tasks( project_id: Optional[str] = None, section_id: Optional[str] = None, label: Optional[str] = None, filter_query: Optional[str] = None ) -> str: """Get tasks from Todoist with optional filtering. Args: project_id: Filter tasks by project ID section_id: Filter tasks by section ID label: Filter tasks by label filter_query: Natural language filter (e.g., 'today', 'overdue', 'p1') """ _check_client() tasks = await todoist_client.get_tasks( project_id=project_id, section_id=section_id, label=label, filter_query=filter_query ) if not tasks: return "No tasks found." task_list = [] for task in tasks: task_info = f"• [{task.id}] {task.content}" if task.due_string or task.due_date: task_info += f" (Due: {task.due_string or task.due_date})" if task.priority > 1: task_info += f" [Priority: {task.priority}]" if task.labels: task_info += f" Labels: {', '.join(task.labels)}" task_list.append(task_info) return f"Found {len(tasks)} tasks:\n" + "\n".join(task_list)
  • Helper method in TodoistClient that performs the actual API call to fetch tasks from Todoist with filtering parameters and parses responses into TodoistTask models.
    async def get_tasks(self, project_id: Optional[str] = None, section_id: Optional[str] = None, label: Optional[str] = None, filter_query: Optional[str] = None) -> List[TodoistTask]: """Get tasks with optional filtering.""" params = {} if project_id: params["project_id"] = project_id if section_id: params["section_id"] = section_id if label: params["label"] = label if filter_query: params["filter"] = filter_query data = await self._request("GET", "/tasks", params=params) return [TodoistTask(**task) for task in data]
  • Pydantic model defining the structure of TodoistTask used in get_tasks response parsing.
    class TodoistTask(BaseModel): """Represents a Todoist task.""" id: str content: str description: str = "" is_completed: bool = False labels: List[str] = [] priority: int = 1 due_string: Optional[str] = None due_date: Optional[str] = None project_id: str = "" section_id: Optional[str] = None parent_id: Optional[str] = None order: int = 0 url: str = "" created_at: str = ""

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/dan-bailey/todoist-mcp'

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