Skip to main content
Glama

Add Todo

add_todo

Create a new task with title, optional description, priority, due date, and tags for organized task management.

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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
okYes
errorNo
resultNo

Implementation Reference

  • The handler function for the 'add_todo' MCP tool. It destructures input parameters, calls the storage addTodo function, and returns a formatted tool response or error.
    async ({ title, description, priority, dueDate, tags }) => {
      try {
        const todo = await addTodo(title, description, priority, dueDate, tags);
        return createToolResponse({
          ok: true,
          result: {
            item: todo,
            summary: `Added todo "${todo.title}"`,
            nextActions: ['list_todos', 'update_todo', 'complete_todo'],
          },
        });
      } catch (err) {
        return createErrorResponse('E_ADD_TODO', getErrorMessage(err));
      }
    }
  • Registration of the 'add_todo' tool with the MCP server, including metadata, schemas, and inline handler.
    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);
            return createToolResponse({
              ok: true,
              result: {
                item: todo,
                summary: `Added todo "${todo.title}"`,
                nextActions: ['list_todos', 'update_todo', 'complete_todo'],
              },
            });
          } catch (err) {
            return createErrorResponse('E_ADD_TODO', getErrorMessage(err));
          }
        }
      );
    }
  • Zod schema for 'add_todo' input validation (TodoInputSchema aliased as AddTodoSchema).
    const TodoInputSchema: ZodType<TodoInput> = z.strictObject({
      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'),
    });
    
    export const AddTodoSchema: ZodType<TodoInput> = TodoInputSchema;
  • Helper function that adds a single todo item by wrapping the batch addTodos function from storage layer.
    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;
    }
  • Top-level call to register the 'add_todo' tool as part of all tools registration.
    registerAddTodo(server);

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other Tools

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