remove-metadata
Eliminate unwanted metadata from tasks in Todo.txt files by specifying the task ID and keys to remove, ensuring cleaner and more organized task management.
Instructions
Remove specific metadata keys from a task by ID.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| keys | Yes | ||
| taskId | Yes |
Implementation Reference
- src/tools.ts:258-278 (handler)The handler function that implements the 'remove-metadata' tool logic. Loads the todo tasks, finds the task by 1-based ID using helper, removes each specified key from the task's extensions (metadata), persists changes, and returns success or error.async ({ taskId, keys }) => { const tasks = await loadTasks(); const idx = getTaskIndex(taskId, tasks); if (idx === null) { return { content: [ { type: "text", text: "Invalid task ID." }, ], isError: true, }; } keys.forEach((key: string) => { tasks[idx].removeExtension(key); }); await saveTasks(tasks); return { content: [ { type: "text", text: "Metadata removed successfully." }, ], }; }
- src/tools.ts:254-257 (schema)Input schema definition using Zod for validating the tool parameters: taskId as number, keys as array of strings.{ taskId: z.number(), keys: z.array(z.string()), },
- src/tools.ts:251-279 (registration)The server.tool call that registers the 'remove-metadata' tool with the MCP server, providing name, description, input schema, and handler function.server.tool( "remove-metadata", "Remove specific metadata keys from a task by ID.", { taskId: z.number(), keys: z.array(z.string()), }, async ({ taskId, keys }) => { const tasks = await loadTasks(); const idx = getTaskIndex(taskId, tasks); if (idx === null) { return { content: [ { type: "text", text: "Invalid task ID." }, ], isError: true, }; } keys.forEach((key: string) => { tasks[idx].removeExtension(key); }); await saveTasks(tasks); return { content: [ { type: "text", text: "Metadata removed successfully." }, ], }; } );