Skip to main content
Glama

filter_tasks_tool

Filter tasks by status, title, description, or creation date to find specific items in your task list.

Instructions

Filter tasks by status and title. Args: status (TaskStatus): The status to filter tasks. Optional value. title (str): The title to filter tasks. Optional value. description (str): The description to filter tasks. Optional value. created_at (str): The creation date to filter tasks. Optional value.

Returns: list[Task]: A list of tasks matching the specified status and title.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
statusNo
titleNo
descriptionNo
created_atNo

Implementation Reference

  • The primary handler function for the 'filter_tasks_tool' tool. It uses the database to filter tasks based on optional criteria (status, title, description, created_at) and returns a list of Task objects.
    @mcp.tool()
    async def filter_tasks_tool(
        ctx: Context[ServerSession, AppContext],
        status: TaskStatus | None = None,
        title: str | None = None,
        description: str | None = None,
        created_at: str | None = None,
    ) -> list[Task]:
        """Filter tasks by status and title.
        Args:
            status (TaskStatus): The status to filter tasks. Optional value.
            title (str): The title to filter tasks. Optional value.
            description (str): The description to filter tasks. Optional value.
            created_at (str): The creation date to filter tasks. Optional value.
    
        Returns:
            list[Task]: A list of tasks matching the specified status and title.
        """
        database: DatabaseABC = ctx.request_context.lifespan_context.db
        tasks = database.filter_tasks(
            title=title or "",
            description=description or "",
            status=status if status is not None else None,
            created_at=created_at or "",
        )
        return [Task(**task.__dict__) for task in tasks]
  • Pydantic models defining TaskStatus enum (used in tool input) and Task model (used for output serialization of filtered tasks).
    from enum import IntEnum
    
    from pydantic import BaseModel, Field
    
    
    class TaskStatus(IntEnum):
        CREATED = 0
        IN_PROGRESS = 1
        COMPLETED = 2
    
    
    class Task(BaseModel):
        id: int = Field(default=None)
        title: str = Field(..., description="The title of the task")
        description: str = Field(default="", description="The description of the task")
        status: TaskStatus = TaskStatus.CREATED
        created_at: str = Field(default=None)
  • The registration of the filter_tasks_tool occurs via the call to create_tasks_tools(mcp), which defines and registers all task-related tools including filter_tasks_tool.
    create_tasks_tools(mcp)

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/chipocrudos/tasks-mcp'

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