Skip to main content
Glama

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
NameRequiredDescriptionDefault
itemsYesTodos to add in a single batch

Implementation Reference

  • 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)); } }
  • 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)); } } ); }
  • 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();
  • 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; }); }
  • Calls registerAddTodos to include 'add_todos' tool when registering all tools.
    registerAddTodos(server);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/j0hanz/todokit-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server