Skip to main content
Glama

add_todo

Create a new task with title, priority, due date, and tags for organization in the Todokit task management system.

Instructions

Add a new todo item

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYesThe title of the todo
descriptionNoOptional description of the todo
priorityNoPriority level (default: normal)
dueDateNoDue date in ISO format (YYYY-MM-DD)
tagsNoTags for categorization

Implementation Reference

  • Registers the 'add_todo' MCP tool, including metadata, schemas, and inline handler function that invokes the storage addTodo helper.
    export function registerAddTodo(server: McpServer): void { server.registerTool( 'add_todo', { title: 'Add Todo', description: 'Add a new todo item', inputSchema: AddTodoSchema, outputSchema: DefaultOutputSchema, annotations: { readOnlyHint: false, idempotentHint: false, }, }, async ({ title, description, priority, dueDate, tags }) => { try { const todo = await addTodo(title, description, priority, dueDate, tags); const structured = { ok: true, result: { item: todo, summary: `Added todo "${todo.title}"`, nextActions: ['list_todos', 'update_todo', 'complete_todo'], }, }; return createToolResponse(structured); } catch (err) { return createErrorResponse('E_ADD_TODO', getErrorMessage(err)); } } ); }
  • The inline handler function executing the core logic: calls addTodo storage helper, formats success/error responses.
    async ({ title, description, priority, dueDate, tags }) => { try { const todo = await addTodo(title, description, priority, dueDate, tags); const structured = { ok: true, result: { item: todo, summary: `Added todo "${todo.title}"`, nextActions: ['list_todos', 'update_todo', 'complete_todo'], }, }; return createToolResponse(structured); } catch (err) { return createErrorResponse('E_ADD_TODO', getErrorMessage(err)); }
  • Defines AddTodoSchema (alias for TodoInputSchema) for input validation of title, description, priority, dueDate, tags.
    const TodoInputSchema = z .object({ title: z.string().min(1).max(200).describe('The title of the todo'), description: z .string() .max(2000) .optional() .describe('Optional description of the todo'), priority: z .enum(['low', 'normal', 'high']) .optional() .describe('Priority level (default: normal)'), dueDate: IsoDateSchema.optional().describe( 'Due date in ISO format (YYYY-MM-DD)' ), tags: z .array(TagSchema) .max(50) .optional() .describe('Tags for categorization'), }) .strict(); export const AddTodoSchema = TodoInputSchema;
  • addTodo helper function invoked by the tool handler; wraps addTodos for single-item addition to persistent storage.
    export async function addTodo( title: string, description?: string, priority: 'low' | 'normal' | 'high' = 'normal', dueDate?: string, tags: string[] = [] ): Promise<Todo> { const [todo] = await addTodos([ { title, description, priority, dueDate, tags }, ]); if (!todo) { throw new Error('Failed to create todo'); } return todo; }
  • Core storage helper for batch-adding todos: reads existing todos, generates new Todo objects with UUIDs and timestamps, appends and persists to todos.json atomically.
    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; }); }

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