complete_todo
Mark a todo item as completed to track task progress and maintain an organized task list.
Instructions
Set completion status for a todo item
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/complete_todo.ts:52-67 (handler)Core handler function that processes input, calls storage completeTodoBySelector, handles outcomes, and returns appropriate tool responses.async function handleCompleteTodo( input: CompleteTodoInput ): Promise<CallToolResult> { const targetCompleted = resolveTargetCompleted(input); const outcome = await completeTodoBySelector( toResolveInput({ id: input.id, query: input.query }), targetCompleted ); if (outcome.kind === 'error') return outcome.response; if (outcome.kind === 'ambiguous') return outcome.response; if (outcome.kind === 'already') { return buildAlreadyStatusResponse(outcome.todo, targetCompleted); } return buildCompletionResponse(outcome.todo, targetCompleted); }
- src/schemas/inputs.ts:68-90 (schema)Zod schema defining the input for the complete_todo tool, including id or query selector and optional completed flag.export const CompleteTodoSchema = z .object({ id: z .string() .min(1) .max(100) .optional() .describe('The ID of the todo to complete'), query: z .string() .min(1) .max(200) .optional() .describe('Search text to find a single todo to complete'), completed: z .boolean() .optional() .describe('Set completion status (default: true)'), }) .strict() .refine((value) => Boolean(value.id ?? value.query), { message: 'Provide id or query to identify the todo', });
- src/tools/complete_todo.ts:69-90 (registration)Registers the 'complete_todo' tool with the MCP server, specifying schema, description, and handler.export function registerCompleteTodo(server: McpServer): void { server.registerTool( 'complete_todo', { title: 'Complete Todo', description: 'Set completion status for a todo item', inputSchema: CompleteTodoSchema, outputSchema: DefaultOutputSchema, annotations: { readOnlyHint: false, idempotentHint: true, }, }, async (input) => { try { return await handleCompleteTodo(input); } catch (err) { return createErrorResponse('E_COMPLETE_TODO', getErrorMessage(err)); } } ); }
- src/lib/storage.ts:496-511 (helper)Storage layer function that resolves the todo by selector, toggles completion status atomically, and persists changes.export async function completeTodoBySelector( input: ResolveTodoInput, completed: boolean ): Promise<CompleteTodoOutcome> { return queueWrite(async () => { const todos = await readTodosFromDisk(); const outcome = unwrapResolution(resolveTodoTargetFromTodos(todos, input)); if (outcome.kind !== 'match') return outcome; const result = completeTodoInList(todos, outcome.todo.id, completed); if (result.kind === 'match') { await persistTodos(todos); } return result; }); }