update-task
Modify existing Microsoft Todo tasks by updating properties like title, due date, importance, status, or categories to keep task information current and accurate.
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 |
|---|---|---|---|
| listId | Yes | ID of the task list | |
| taskId | Yes | ID of the task to update | |
| title | No | New title of the task | |
| body | No | New description or body content of the task | |
| dueDateTime | No | New due date in ISO format (e.g., 2023-12-31T23:59:59Z) | |
| startDateTime | No | New start 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 | |
| reminderDateTime | No | New reminder date and time in ISO format | |
| status | No | New status of the task | |
| categories | No | New categories associated with the task |
Implementation Reference
- src/todo-index.ts:930-1059 (handler)The handler function that executes the update-task tool logic: authenticates, constructs the update body from parameters, makes a PATCH request to Microsoft Graph API /me/todo/lists/{listId}/tasks/{taskId}, and returns success/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 defining the input parameters for the update-task tool, 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)The server.tool registration call that registers the 'update-task' tool with name, description, input schema, and handler function on the MCP server.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}`, }, ], }; } } );