clear_completed
Remove completed tasks from your todo list to maintain focus on pending items and declutter your markdown file.
Instructions
Remove all completed todo items
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:182-192 (handler)MCP tool handler for 'clear_completed': calls todoManager.clearCompleted() and returns formatted response with count of cleared todos.case 'clear_completed': { const count = await this.todoManager.clearCompleted(); return { content: [ { type: 'text', text: `Cleared ${count} completed todo(s)`, }, ], }; }
- src/todoManager.ts:226-249 (helper)Core implementation: filters out completed todos, rewrites the markdown file with remaining todos, handles file write errors, returns count of cleared items.async clearCompleted(): Promise<number> { const todos = (await this.listTodos()).todos; const completedCount = todos.filter((todo) => todo.completed).length; const remainingTodos = todos.filter((todo) => !todo.completed); const markdown = this.formatTodoMarkdown(remainingTodos); try { await writeFile(this.todoFilePath, markdown, 'utf-8'); } catch (error) { if (error instanceof Error && error.message.includes('EACCES')) { throw new Error( `Permission denied: Cannot write to ${this.todoFilePath}. Check file permissions or set TODO_FILE_PATH environment variable to a writable location.` ); } else if (error instanceof Error && error.message.includes('EROFS')) { throw new Error( `Read-only file system: Cannot write to ${this.todoFilePath}. Set TODO_FILE_PATH environment variable to a writable location.` ); } throw error; } return completedCount; }
- src/index.ts:102-110 (registration)Registers the 'clear_completed' tool in the ListTools response, including name, description, and empty input schema (no parameters required).{ name: 'clear_completed', description: 'Remove all completed todo items', inputSchema: { type: 'object', properties: {}, additionalProperties: false, }, },
- src/index.ts:105-109 (schema)Defines the input schema for 'clear_completed' tool: empty object, no required properties.inputSchema: { type: 'object', properties: {}, additionalProperties: false, },