delete-task
Remove a task and its subtasks from a Microsoft Todo list using the task ID and list ID.
Instructions
Delete a task from a Microsoft Todo list. This will remove the task and all its checklist items (subtasks).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| listId | Yes | ID of the task list | |
| taskId | Yes | ID of the task to delete |
Implementation Reference
- src/todo-index.ts:1069-1113 (handler)The handler function for the 'delete-task' tool. It authenticates with Microsoft Graph API using getAccessToken, constructs the DELETE URL for the specific task, calls makeGraphRequest to delete it, and returns a success or error message.async ({ listId, taskId }) => { try { const token = await getAccessToken(); if (!token) { return { content: [ { type: "text", text: "Failed to authenticate with Microsoft API", }, ], }; } // Make a DELETE request to the Microsoft Graph API const url = `${MS_GRAPH_BASE}/me/todo/lists/${listId}/tasks/${taskId}`; console.error(`Deleting task: ${url}`); // The DELETE method doesn't return a response body, so we expect null await makeGraphRequest<null>( url, token, "DELETE" ); // If we get here, the delete was successful (204 No Content) return { content: [ { type: "text", text: `Task with ID: ${taskId} was successfully deleted from list: ${listId}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error deleting task: ${error}`, }, ], }; } }
- src/todo-index.ts:1065-1068 (schema)Zod input schema defining the required parameters: listId (string) and taskId (string).{ listId: z.string().describe("ID of the task list"), taskId: z.string().describe("ID of the task to delete") },
- src/todo-index.ts:1062-1114 (registration)Registration of the 'delete-task' tool using server.tool, including name, description, schema, and inline handler function.server.tool( "delete-task", "Delete a task from a Microsoft Todo list. This will remove the task and all its checklist items (subtasks).", { listId: z.string().describe("ID of the task list"), taskId: z.string().describe("ID of the task to delete") }, async ({ listId, taskId }) => { try { const token = await getAccessToken(); if (!token) { return { content: [ { type: "text", text: "Failed to authenticate with Microsoft API", }, ], }; } // Make a DELETE request to the Microsoft Graph API const url = `${MS_GRAPH_BASE}/me/todo/lists/${listId}/tasks/${taskId}`; console.error(`Deleting task: ${url}`); // The DELETE method doesn't return a response body, so we expect null await makeGraphRequest<null>( url, token, "DELETE" ); // If we get here, the delete was successful (204 No Content) return { content: [ { type: "text", text: `Task with ID: ${taskId} was successfully deleted from list: ${listId}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error deleting task: ${error}`, }, ], }; } } );