Skip to main content
Glama

delete_todo

Remove a task from your todo list. This tool supports dry-run mode to preview deletions before making changes to your local JSON storage.

Instructions

Delete a todo item (supports dry-run)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler functions executing the delete_todo tool logic: dry-run resolution and response building, live deletion via storage helper, and dispatcher based on dryRun flag.
    async function handleDeleteTodoDryRun( input: DeleteTodoInput ): Promise<CallToolResult> { const todos = await getTodos(); const outcome = unwrapResolution( resolveTodoTargetFromTodos( todos, toResolveInput({ id: input.id, query: input.query }) ) ); if (outcome.kind === 'error') return outcome.response; if (outcome.kind === 'ambiguous') { return handleAmbiguousDelete(outcome, true); } return handleMatchDelete(outcome.todo, true); } async function handleDeleteTodoLive( input: DeleteTodoInput ): Promise<CallToolResult> { const outcome = await deleteTodoBySelector( toResolveInput({ id: input.id, query: input.query }) ); if (outcome.kind === 'error' || outcome.kind === 'ambiguous') { return outcome.response; } return handleMatchDelete(outcome.todo, false); } async function handleDeleteTodo( input: DeleteTodoInput ): Promise<CallToolResult> { const dryRun = input.dryRun ?? false; if (dryRun) { return handleDeleteTodoDryRun(input); } return handleDeleteTodoLive(input); }
  • Zod input schema for the delete_todo tool, validating id or query selector and optional dryRun flag.
    export const DeleteTodoSchema = z .object({ id: z .string() .min(1) .max(100) .optional() .describe('The ID of the todo to delete'), query: z .string() .min(1) .max(200) .optional() .describe('Search text to find a single todo to delete'), dryRun: z .boolean() .optional() .describe('Simulate the deletion without changing data'), }) .strict() .refine((value) => Boolean(value.id ?? value.query), { message: 'Provide id or query to identify the todo', });
  • Registers the 'delete_todo' tool on the MCP server with metadata, schemas, annotations, and error-handling wrapper around the core 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)); } } ); }
  • Invocation of registerDeleteTodo within the registerAllTools function to include delete_todo in the full toolset.
    registerDeleteTodo(server);
  • Storage layer helper that resolves the todo selector, removes the matching todo from the list, persists changes, and returns the outcome.
    export async function deleteTodoBySelector( input: ResolveTodoInput ): Promise<MatchOutcome> { return queueWrite(async () => { const todos = await readTodosFromDisk(); const outcome = unwrapResolution(resolveTodoTargetFromTodos(todos, input)); if (outcome.kind !== 'match') return outcome; const index = todos.findIndex((todo) => todo.id === outcome.todo.id); if (index === -1) { return createNotFoundOutcome(outcome.todo.id); } const [removed] = todos.splice(index, 1); if (!removed) { return createNotFoundOutcome(outcome.todo.id); } await persistTodos(todos); return { kind: 'match', todo: removed }; }); }

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