search_todos
Filter and locate tasks by title, description, status, or priority to streamline task management and improve productivity on the Todo List MCP Server.
Instructions
Search todos by title or description
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| priority | No | Filter by priority | |
| searchTerm | Yes | Search term for title or description | |
| status | No | Filter by status | all |
Implementation Reference
- src/handlers/toolHandlers.ts:240-274 (handler)The main handler function for the 'search_todos' tool. Validates input using SearchTodosSchema, calls the todoService.searchTodos method with appropriate filters, and returns a formatted response with search results or error.async handleSearchTodos(request: CallToolRequest): Promise<CallToolResult> { try { const sanitizedArgs = sanitizeInput(request.params.arguments); const validatedRequest = validateData(SearchTodosSchema, sanitizedArgs); const filters: any = {}; if (validatedRequest.status !== undefined) { filters.status = validatedRequest.status; } if (validatedRequest.priority !== undefined) { filters.priority = validatedRequest.priority; } const todos = this.todoService.searchTodos(validatedRequest.searchTerm, filters); return { content: [ { type: "text", text: `🔍 Busca por "${validatedRequest.searchTerm}" retornou ${todos.length} resultado(s):\n\n${JSON.stringify(todos, null, 2)}`, }, ], }; } catch (error) { const errorResponse = createErrorResponse(error, "buscar todos"); return { content: [ { type: "text", text: `❌ ${errorResponse.error}\n${errorResponse.details || ""}`, }, ], }; } }
- src/schemas/todo.schemas.ts:59-63 (schema)Zod schema for input validation of the search_todos tool, defining searchTerm (required), status (optional, default 'all'), and priority (optional).export const SearchTodosSchema = z.object({ searchTerm: NonEmptyStringSchema.min(1, 'Termo de busca é obrigatório'), status: z.enum(['all', 'completed', 'pending']).default('all'), priority: z.enum(['low', 'medium', 'high']).optional() })
- src/config/toolDefinitions.ts:146-170 (registration)MCP tool definition/registration for 'search_todos', including name, description, and JSON schema for input parameters.name: "search_todos", description: "Search todos by title or description", inputSchema: { type: "object", properties: { searchTerm: { type: "string", minLength: 1, description: "Search term for title or description", }, status: { type: "string", enum: ["all", "completed", "pending"], description: "Filter by status", default: "all", }, priority: { type: "string", enum: ["low", "medium", "high"], description: "Filter by priority", }, }, required: ["searchTerm"], }, },
- Helper method in TodoService that performs the search by passing searchTerm and filters to getAllTodos, which applies filtering logic including text search in title and description.searchTodos(searchTerm: string, filters?: Omit<TodoFilters, 'searchTerm'>): Todo[] { return this.getAllTodos({ ...filters, searchTerm }); }