create-task-list
Create a new task list in Microsoft Todo to organize tasks into categories or projects. Specify a display name to categorize your tasks effectively.
Instructions
Create a new task list (top-level container) in Microsoft Todo to help organize your tasks into categories or projects.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| displayName | Yes | Name of the new task list |
Implementation Reference
- src/todo-index.ts:485-541 (handler)The handler function that implements the core logic of the 'create-task-list' tool. It retrieves an access token, makes a POST request to the Microsoft Graph API endpoint `/me/todo/lists` with the provided displayName, handles errors, and returns a formatted success message with the new list's details.async ({ displayName }) => { try { const token = await getAccessToken(); if (!token) { return { content: [ { type: "text", text: "Failed to authenticate with Microsoft API", }, ], }; } // Prepare the request body const requestBody = { displayName }; // Make the API request to create the task list const response = await makeGraphRequest<TaskList>( `${MS_GRAPH_BASE}/me/todo/lists`, token, "POST", requestBody ); if (!response) { return { content: [ { type: "text", text: `Failed to create task list: ${displayName}`, }, ], }; } return { content: [ { type: "text", text: `Task list created successfully!\nName: ${response.displayName}\nID: ${response.id}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error creating task list: ${error}`, }, ], }; } }
- src/todo-index.ts:482-484 (schema)The input schema for the 'create-task-list' tool, using Zod to validate the required 'displayName' parameter as a string.{ displayName: z.string().describe("Name of the new task list") },
- src/todo-index.ts:479-542 (registration)The registration of the 'create-task-list' tool on the MCP server using server.tool(), specifying the tool name, description, input schema, and handler function.server.tool( "create-task-list", "Create a new task list (top-level container) in Microsoft Todo to help organize your tasks into categories or projects.", { displayName: z.string().describe("Name of the new task list") }, async ({ displayName }) => { try { const token = await getAccessToken(); if (!token) { return { content: [ { type: "text", text: "Failed to authenticate with Microsoft API", }, ], }; } // Prepare the request body const requestBody = { displayName }; // Make the API request to create the task list const response = await makeGraphRequest<TaskList>( `${MS_GRAPH_BASE}/me/todo/lists`, token, "POST", requestBody ); if (!response) { return { content: [ { type: "text", text: `Failed to create task list: ${displayName}`, }, ], }; } return { content: [ { type: "text", text: `Task list created successfully!\nName: ${response.displayName}\nID: ${response.id}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error creating task list: ${error}`, }, ], }; } } );