Skip to main content
Glama

Delete Todo

delete_todo
DestructiveIdempotent

Remove a todo item from your task list, with optional dry-run mode to preview changes before deletion.

Instructions

Delete a todo item (supports dry-run)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
okYes
errorNo
resultNo

Implementation Reference

  • Handler functions (handleDeleteTodo, handleDeleteTodoDryRun, handleDeleteTodoLive) that implement the core logic for deleting a todo item, supporting dry-run mode and selector-based resolution.
    async function handleDeleteTodoDryRun(
      input: DeleteTodoInput
    ): Promise<CallToolResult> {
      const todos = await getTodos();
      const selector =
        input.id !== undefined ? { id: input.id } : { query: input.query };
      const outcome = unwrapResolution(
        resolveTodoTargetFromTodos(todos, toResolveInput(selector))
      );
      if (outcome.kind === 'error') return outcome.response;
      if (outcome.kind === 'ambiguous') {
        return buildDryRunMultiple(outcome.previews, outcome.matches.length);
      }
      return buildDeleteResponse(outcome.todo, true);
    }
    
    async function handleDeleteTodoLive(
      input: DeleteTodoInput
    ): Promise<CallToolResult> {
      const selector =
        input.id !== undefined ? { id: input.id } : { query: input.query };
      const outcome = await deleteTodoBySelector(toResolveInput(selector));
      if (outcome.kind === 'error' || outcome.kind === 'ambiguous') {
        return outcome.response;
      }
      return buildDeleteResponse(outcome.todo, false);
    }
    
    async function handleDeleteTodo(
      input: DeleteTodoInput
    ): Promise<CallToolResult> {
      const dryRun = input.dryRun ?? false;
      if (dryRun) {
        return handleDeleteTodoDryRun(input);
      }
      return handleDeleteTodoLive(input);
    }
  • Registration of the 'delete_todo' tool with the MCP server, specifying title, description, schemas, annotations, and handler.
    export function registerDeleteTodo(server: McpServer): void {
      server.registerTool(
        'delete_todo',
        {
          title: 'Delete Todo',
          description: 'Delete a todo item (supports dry-run)',
          inputSchema: DeleteTodoSchema,
          outputSchema: DefaultOutputSchema,
          annotations: {
            readOnlyHint: false,
            idempotentHint: true,
            destructiveHint: true,
          },
        },
        async (input) => {
          try {
            return await handleDeleteTodo(input);
          } catch (err) {
            return createErrorResponse('E_DELETE_TODO', getErrorMessage(err));
          }
        }
      );
    }
  • DeleteTodoSchema: Zod schema defining the input for delete_todo tool, supporting ID or query selector with optional dryRun flag.
    const deleteTodoSelector = buildSelectorSchemas(
      'The ID of the todo to delete',
      'Search text to find a single todo to delete'
    );
    
    export const DeleteTodoSchema: ZodType<DeleteTodoInput> = z.union([
      deleteTodoSelector.byId.extend({
        dryRun: z
          .boolean()
          .optional()
          .describe('Simulate the deletion without changing data'),
      }),
      deleteTodoSelector.byQuery.extend({
        dryRun: z
          .boolean()
          .optional()
          .describe('Simulate the deletion without changing data'),
      }),
    ]);
  • deleteTodoBySelector: Storage helper that resolves a todo by selector and deletes it from the todos list, returning match outcome.
    export async function deleteTodoBySelector(
      input: ResolveTodoInput
    ): Promise<MatchOutcome> {
      return withTodos<MatchOutcome>((todos) => {
        const outcome = unwrapResolution(resolveTodoTargetFromTodos(todos, input));
        if (outcome.kind !== 'match') {
          return { todos, result: outcome };
        }
    
        const remaining = todos.filter((todo) => todo.id !== outcome.todo.id);
        if (remaining.length === todos.length) {
          return {
            todos,
            result: createNotFoundOutcome(outcome.todo.id),
          };
        }
    
        return { todos: remaining, result: { kind: 'match', todo: outcome.todo } };
      });
    }

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