update-task
Modify existing tasks in Microsoft Todo by updating properties such as title, due date, importance, status, and more, ensuring tasks stay organized and relevant.
Instructions
Update an existing task in Microsoft Todo. Allows changing any properties of the task including title, due date, importance, etc.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| body | No | New description or body content of the task | |
| categories | No | New categories associated with the task | |
| dueDateTime | No | New due date in ISO format (e.g., 2023-12-31T23:59:59Z) | |
| importance | No | New task importance | |
| isReminderOn | No | Whether to enable reminder for this task | |
| listId | Yes | ID of the task list | |
| reminderDateTime | No | New reminder date and time in ISO format | |
| startDateTime | No | New start date in ISO format (e.g., 2023-12-31T23:59:59Z) | |
| status | No | New status of the task | |
| taskId | Yes | ID of the task to update | |
| title | No | New title of the task |
Implementation Reference
- src/todo-index.ts:930-1059 (handler)The handler function for the 'update-task' tool. It authenticates, constructs a PATCH request body with the provided optional parameters, calls makeGraphRequest to update the task via Microsoft Graph API, and returns success or error messages.async ({ listId, taskId, title, body, dueDateTime, startDateTime, importance, isReminderOn, reminderDateTime, status, categories }) => { try { const token = await getAccessToken(); if (!token) { return { content: [ { type: "text", text: "Failed to authenticate with Microsoft API", }, ], }; } // Construct the task update body with all provided properties const taskBody: any = {}; // Add optional properties if provided if (title !== undefined) { taskBody.title = title; } if (body !== undefined) { taskBody.body = { content: body, contentType: "text" }; } if (dueDateTime !== undefined) { if (dueDateTime === "") { // Remove the due date by setting it to null taskBody.dueDateTime = null; } else { taskBody.dueDateTime = { dateTime: dueDateTime, timeZone: "UTC", }; } } if (startDateTime !== undefined) { if (startDateTime === "") { // Remove the start date by setting it to null taskBody.startDateTime = null; } else { taskBody.startDateTime = { dateTime: startDateTime, timeZone: "UTC", }; } } if (importance !== undefined) { taskBody.importance = importance; } if (isReminderOn !== undefined) { taskBody.isReminderOn = isReminderOn; } if (reminderDateTime !== undefined) { if (reminderDateTime === "") { // Remove the reminder date by setting it to null taskBody.reminderDateTime = null; } else { taskBody.reminderDateTime = { dateTime: reminderDateTime, timeZone: "UTC", }; } } if (status !== undefined) { taskBody.status = status; } if (categories !== undefined) { taskBody.categories = categories; } // Make sure we have at least one property to update if (Object.keys(taskBody).length === 0) { return { content: [ { type: "text", text: "No properties provided for update. Please specify at least one property to change.", }, ], }; } const response = await makeGraphRequest<Task>( `${MS_GRAPH_BASE}/me/todo/lists/${listId}/tasks/${taskId}`, token, "PATCH", taskBody ); if (!response) { return { content: [ { type: "text", text: `Failed to update task with ID: ${taskId} in list: ${listId}`, }, ], }; } return { content: [ { type: "text", text: `Task updated successfully!\nID: ${response.id}\nTitle: ${response.title}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error updating task: ${error}`, }, ], }; } }
- src/todo-index.ts:917-929 (schema)Zod schema for input validation of the 'update-task' tool parameters including required listId and taskId, and optional fields for updating task properties.{ listId: z.string().describe("ID of the task list"), taskId: z.string().describe("ID of the task to update"), title: z.string().optional().describe("New title of the task"), body: z.string().optional().describe("New description or body content of the task"), dueDateTime: z.string().optional().describe("New due date in ISO format (e.g., 2023-12-31T23:59:59Z)"), startDateTime: z.string().optional().describe("New start date in ISO format (e.g., 2023-12-31T23:59:59Z)"), importance: z.enum(["low", "normal", "high"]).optional().describe("New task importance"), isReminderOn: z.boolean().optional().describe("Whether to enable reminder for this task"), reminderDateTime: z.string().optional().describe("New reminder date and time in ISO format"), status: z.enum(["notStarted", "inProgress", "completed", "waitingOnOthers", "deferred"]).optional().describe("New status of the task"), categories: z.array(z.string()).optional().describe("New categories associated with the task") },
- src/todo-index.ts:914-1060 (registration)Registration of the 'update-task' MCP tool using server.tool(), specifying name, description, input schema, and handler function.server.tool( "update-task", "Update an existing task in Microsoft Todo. Allows changing any properties of the task including title, due date, importance, etc.", { listId: z.string().describe("ID of the task list"), taskId: z.string().describe("ID of the task to update"), title: z.string().optional().describe("New title of the task"), body: z.string().optional().describe("New description or body content of the task"), dueDateTime: z.string().optional().describe("New due date in ISO format (e.g., 2023-12-31T23:59:59Z)"), startDateTime: z.string().optional().describe("New start date in ISO format (e.g., 2023-12-31T23:59:59Z)"), importance: z.enum(["low", "normal", "high"]).optional().describe("New task importance"), isReminderOn: z.boolean().optional().describe("Whether to enable reminder for this task"), reminderDateTime: z.string().optional().describe("New reminder date and time in ISO format"), status: z.enum(["notStarted", "inProgress", "completed", "waitingOnOthers", "deferred"]).optional().describe("New status of the task"), categories: z.array(z.string()).optional().describe("New categories associated with the task") }, async ({ listId, taskId, title, body, dueDateTime, startDateTime, importance, isReminderOn, reminderDateTime, status, categories }) => { try { const token = await getAccessToken(); if (!token) { return { content: [ { type: "text", text: "Failed to authenticate with Microsoft API", }, ], }; } // Construct the task update body with all provided properties const taskBody: any = {}; // Add optional properties if provided if (title !== undefined) { taskBody.title = title; } if (body !== undefined) { taskBody.body = { content: body, contentType: "text" }; } if (dueDateTime !== undefined) { if (dueDateTime === "") { // Remove the due date by setting it to null taskBody.dueDateTime = null; } else { taskBody.dueDateTime = { dateTime: dueDateTime, timeZone: "UTC", }; } } if (startDateTime !== undefined) { if (startDateTime === "") { // Remove the start date by setting it to null taskBody.startDateTime = null; } else { taskBody.startDateTime = { dateTime: startDateTime, timeZone: "UTC", }; } } if (importance !== undefined) { taskBody.importance = importance; } if (isReminderOn !== undefined) { taskBody.isReminderOn = isReminderOn; } if (reminderDateTime !== undefined) { if (reminderDateTime === "") { // Remove the reminder date by setting it to null taskBody.reminderDateTime = null; } else { taskBody.reminderDateTime = { dateTime: reminderDateTime, timeZone: "UTC", }; } } if (status !== undefined) { taskBody.status = status; } if (categories !== undefined) { taskBody.categories = categories; } // Make sure we have at least one property to update if (Object.keys(taskBody).length === 0) { return { content: [ { type: "text", text: "No properties provided for update. Please specify at least one property to change.", }, ], }; } const response = await makeGraphRequest<Task>( `${MS_GRAPH_BASE}/me/todo/lists/${listId}/tasks/${taskId}`, token, "PATCH", taskBody ); if (!response) { return { content: [ { type: "text", text: `Failed to update task with ID: ${taskId} in list: ${listId}`, }, ], }; } return { content: [ { type: "text", text: `Task updated successfully!\nID: ${response.id}\nTitle: ${response.title}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error updating task: ${error}`, }, ], }; } } );