Skip to main content
Glama
jhirono

Microsoft Todo MCP Service

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
NameRequiredDescriptionDefault
displayNameYesName of the new task list

Implementation Reference

  • 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}`,
            },
          ],
        };
      }
    }
  • 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")
    },
  • 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}`,
              },
            ],
          };
        }
      }
    );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jhirono/todoMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server