search_todos
Find tasks in your todo list by searching titles or descriptions, with options to filter by status and priority.
Instructions
Search todos by title or description
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| searchTerm | Yes | Search term for title or description | |
| status | No | Filter by status | all |
| priority | No | Filter by priority |
Implementation Reference
- src/handlers/toolHandlers.ts:240-274 (handler)Main handler function for 'search_todos' tool: validates input with SearchTodosSchema, constructs filters, calls todoService.searchTodos, and returns formatted 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 defining input validation for search_todos tool: requires searchTerm, optional status and priority filters.
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:145-170 (registration)MCP tool registration definition including name, description, and input schema for 'search_todos'.
{ 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 service method implementing the search logic by delegating to getAllTodos with searchTerm and filters.
searchTodos(searchTerm: string, filters?: Omit<TodoFilters, 'searchTerm'>): Todo[] { return this.getAllTodos({ ...filters, searchTerm }); }