add_todos
Add multiple todo items in a single batch operation to manage tasks 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-36 (handler)The handler function for the 'add_todos' tool. It processes the input items by calling addTodos from storage, creates a success response with the added todos, or handles errors.async ({ items }) => { try { const todos = await addTodos(items); return createToolResponse({ ok: true, result: { items: todos, summary: `Added ${String(todos.length)} todos`, nextActions: ['list_todos', 'update_todo'], }, }); } catch (err) { return createErrorResponse('E_ADD_TODOS', getErrorMessage(err)); } }
- src/schemas/inputs.ts:147-153 (schema)Zod schema defining the input structure for add_todos: an array of TodoInput objects with validation.export const AddTodosSchema: ZodType<AddTodosInput> = z.strictObject({ items: z .array(TodoInputSchema) .min(1) .max(50) .describe('Todos to add in a single batch'), });
- src/tools/add_todos.ts:9-38 (registration)Registers the 'add_todos' tool on the MCP server with schema, description, and 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); return createToolResponse({ ok: true, result: { items: todos, summary: `Added ${String(todos.length)} todos`, nextActions: ['list_todos', 'update_todo'], }, }); } catch (err) { return createErrorResponse('E_ADD_TODOS', getErrorMessage(err)); } } ); }
- src/lib/storage.ts:105-111 (helper)Helper function that creates new Todo objects from input and appends them to the todos list in storage.export function addTodos(items: NewTodoInput[]): Promise<Todo[]> { const timestamp = new Date().toISOString(); return withTodos((todos) => { const newTodos = items.map((item) => createNewTodo(item, timestamp)); return { todos: [...todos, ...newTodos], result: newTodos }; }); }
- src/tools/index.ts:13-13 (registration)Invokes the registration of the add_todos tool as part of registering all tools.registerAddTodos(server);