Skip to main content
Glama

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

Implementation Reference

  • 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)); } }
  • 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'), });
  • 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)); } } ); }
  • 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 }; }); }
  • Invokes the registration of the add_todos tool as part of 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