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
| Name | Required | Description | Default |
|---|---|---|---|
| status | No | ||
| title | No | ||
| description | No | ||
| created_at | No |
Implementation Reference
- src/tools/tasks.py:109-134 (handler)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]
- src/models/tasks.py:1-18 (schema)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)
- src/config/server.py:35-35 (registration)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)