add_todos
Add multiple todo items in a single batch operation to manage tasks efficiently with titles, descriptions, priorities, due dates, and tags.
Instructions
Add multiple todo items in one call
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| items | Yes | Todos to add in a single batch |
Implementation Reference
- src/tools/add_todos.ts:22-37 (handler)Handler function that executes the 'add_todos' tool: validates input, calls storage.addTodos, formats success response with added todos, or error response.async ({ items }) => { try { const todos = await addTodos(items); const structured = { ok: true, result: { items: todos, summary: `Added ${String(todos.length)} todos`, nextActions: ['list_todos', 'update_todo'], }, }; return createToolResponse(structured); } catch (err) { return createErrorResponse('E_ADD_TODOS', getErrorMessage(err)); } }
- src/tools/add_todos.ts:9-39 (registration)Registers the 'add_todos' tool with MCP server, including title, description, schemas, annotations, and the handler function.export function registerAddTodos(server: McpServer): void { server.registerTool( 'add_todos', { title: 'Add Todos (Batch)', description: 'Add multiple todo items in one call', inputSchema: AddTodosSchema, outputSchema: DefaultOutputSchema, annotations: { readOnlyHint: false, idempotentHint: false, }, }, async ({ items }) => { try { const todos = await addTodos(items); const structured = { ok: true, result: { items: todos, summary: `Added ${String(todos.length)} todos`, nextActions: ['list_todos', 'update_todo'], }, }; return createToolResponse(structured); } catch (err) { return createErrorResponse('E_ADD_TODOS', getErrorMessage(err)); } } ); }
- src/schemas/inputs.ts:34-42 (schema)Zod schema for 'add_todos' tool input: array of todo items (1-50), each with title, optional description, priority, dueDate, tags.export const AddTodosSchema = z .object({ items: z .array(TodoInputSchema) .min(1) .max(50) .describe('Todos to add in a single batch'), }) .strict();
- src/lib/storage.ts:270-290 (helper)Core storage function that appends new todos to the JSON file atomically, generates IDs, timestamps, normalizes tags, persists changes.export async function addTodos(items: NewTodoInput[]): Promise<Todo[]> { return queueWrite(async () => { const todos = await readTodosFromDisk(); const timestamp = new Date().toISOString(); const newTodos: Todo[] = items.map((item) => ({ id: randomUUID(), title: item.title, description: item.description, completed: false, priority: item.priority ?? 'normal', dueDate: item.dueDate, tags: normalizeTags(item.tags ?? []), createdAt: timestamp, updatedAt: timestamp, completedAt: undefined, })); const nextTodos = [...todos, ...newTodos]; await persistTodos(nextTodos); return newTodos; }); }
- src/tools/index.ts:12-12 (registration)Calls registerAddTodos to include 'add_todos' tool when registering all tools.registerAddTodos(server);