list_todos
Retrieve all todo items in an organized format to view current tasks and track progress efficiently.
Instructions
Return all todos in a structured format.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/server.ts:53-70 (registration)Registration of the 'list_todos' tool using server.registerTool, including schema and handler.server.registerTool( "list_todos", { title: "List Todos", description: "Return all todos in a structured format.", inputSchema: {}, outputSchema: { todos: z.array(TodoSchema), }, }, async () => { const todos = await readTodos(); return { structuredContent: { todos }, content: [{ type: "text", text: JSON.stringify({ todos }, null, 2) }], }; } );
- src/server.ts:63-69 (handler)The handler function for 'list_todos' that reads todos from storage and returns structured content.async () => { const todos = await readTodos(); return { structuredContent: { todos }, content: [{ type: "text", text: JSON.stringify({ todos }, null, 2) }], }; }
- src/server.ts:11-15 (schema)Zod schema for Todo type, used in the outputSchema of list_todos.export const TodoSchema = z.object({ id: z.number().int().positive(), title: z.string().min(1), done: z.boolean(), });
- src/server.ts:20-27 (helper)Helper function to read todos from the JSON file database.async function readTodos(): Promise<Todo[]> { try { const s = await fs.readFile(DB_PATH, "utf-8"); return JSON.parse(s); } catch { return []; } }
- src/server.ts:55-62 (schema)Tool metadata including title, description, inputSchema (empty), and outputSchema referencing TodoSchema.{ title: "List Todos", description: "Return all todos in a structured format.", inputSchema: {}, outputSchema: { todos: z.array(TodoSchema), }, },