Skip to main content
Glama

get_sections

Retrieve sections from a Todoist project to organize tasks by category or workflow stage. Specify a project ID to filter results.

Instructions

Get sections from a project.

Args:
    project_id: Project ID to get sections from (optional)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idNo

Implementation Reference

  • MCP tool handler for 'get_sections': registers the tool, checks client, fetches sections via TodoistClient, formats and returns as string list.
    @mcp.tool()
    async def get_sections(project_id: Optional[str] = None) -> str:
        """Get sections from a project.
        
        Args:
            project_id: Project ID to get sections from (optional)
        """
        _check_client()
        
        sections = await todoist_client.get_sections(project_id=project_id)
        
        if not sections:
            return "No sections found."
        
        section_list = []
        for section in sections:
            section_list.append(f"• [{section.id}] {section.name} (Project: {section.project_id})")
        
        return f"Found {len(sections)} sections:\n" + "\n".join(section_list)
  • Core implementation in TodoistClient: makes API GET request to /sections endpoint with optional project_id filter, parses response into TodoistSection models.
    async def get_sections(self, project_id: Optional[str] = None) -> List[TodoistSection]:
        """Get sections, optionally filtered by project."""
        params = {}
        if project_id:
            params["project_id"] = project_id
        
        data = await self._request("GET", "/sections", params=params)
        return [TodoistSection(**section) for section in data]
  • Pydantic model defining the structure of TodoistSection used for response typing and parsing.
    class TodoistSection(BaseModel):
        """Represents a Todoist section."""
        id: str
        project_id: str
        order: int
        name: str
  • @mcp.tool() decorator registers the get_sections function as an MCP tool.
    @mcp.tool()

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