Skip to main content
Glama
jhirono

Microsoft Todo MCP Service

by jhirono

delete-checklist-item

Remove a specific subtask from a Microsoft Todo task while keeping the parent task intact. Delete checklist items to clean up completed or unnecessary subtasks.

Instructions

Delete a checklist item (subtask) from a task. This removes just the specific subtask, not the parent task.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
listIdYesID of the task list
taskIdYesID of the task
checklistItemIdYesID of the checklist item to delete

Implementation Reference

  • The handler function for the 'delete-checklist-item' tool. It authenticates, constructs the Microsoft Graph API DELETE URL for the specific checklist item, calls makeGraphRequest to delete it, and returns success or error messages.
    async ({ listId, taskId, checklistItemId }) => {
      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}/checklistItems/${checklistItemId}`;
        console.error(`Deleting checklist item: ${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: `Checklist item with ID: ${checklistItemId} was successfully deleted from task: ${taskId}`,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error deleting checklist item: ${error}`,
            },
          ],
        };
      }
    }
  • Zod input schema defining the required parameters: listId, taskId, and checklistItemId for identifying the checklist item to delete.
    {
      listId: z.string().describe("ID of the task list"),
      taskId: z.string().describe("ID of the task"),
      checklistItemId: z.string().describe("ID of the checklist item to delete")
    },
  • The server.tool registration for the 'delete-checklist-item' tool, including name, description, input schema, and handler function.
    server.tool(
      "delete-checklist-item",
      "Delete a checklist item (subtask) from a task. This removes just the specific subtask, not the parent task.",
      {
        listId: z.string().describe("ID of the task list"),
        taskId: z.string().describe("ID of the task"),
        checklistItemId: z.string().describe("ID of the checklist item to delete")
      },
      async ({ listId, taskId, checklistItemId }) => {
        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}/checklistItems/${checklistItemId}`;
          console.error(`Deleting checklist item: ${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: `Checklist item with ID: ${checklistItemId} was successfully deleted from task: ${taskId}`,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error deleting checklist item: ${error}`,
              },
            ],
          };
        }
      }
    );
  • Helper function makeGraphRequest used by the handler to make authenticated HTTP requests to Microsoft Graph API, including the DELETE call.
    async function makeGraphRequest<T>(url: string, token: string, method = "GET", body?: any): Promise<T | null> {
      const headers = {
        "User-Agent": USER_AGENT,
        "Accept": "application/json",
        "Authorization": `Bearer ${token}`,
        "Content-Type": "application/json"
      };
    
      try {
        const options: RequestInit = { 
          method, 
          headers 
        };
    
        if (body && (method === "POST" || method === "PATCH")) {
          options.body = JSON.stringify(body);
        }
    
        console.error(`Making request to: ${url}`);
        console.error(`Request options: ${JSON.stringify({
          method,
          headers: {
            ...headers,
            Authorization: 'Bearer [REDACTED]'
          }
        })}`);
    
        const response = await fetch(url, options);
        
        if (!response.ok) {
          const errorText = await response.text();
          console.error(`HTTP error! status: ${response.status}, body: ${errorText}`);
          
          // Check for the specific MailboxNotEnabledForRESTAPI error
          if (errorText.includes('MailboxNotEnabledForRESTAPI')) {
            console.error(`
    =================================================================
    ERROR: MailboxNotEnabledForRESTAPI
    
    The Microsoft To Do API is not available for personal Microsoft accounts 
    (outlook.com, hotmail.com, live.com, etc.) through the Graph API.
    
    This is a limitation of the Microsoft Graph API, not an authentication issue.
    Microsoft only allows To Do API access for Microsoft 365 business accounts.
    
    You can still use Microsoft To Do through the web interface or mobile apps,
    but API access is restricted for personal accounts.
    =================================================================
            `);
            
            throw new Error("Microsoft To Do API is not available for personal Microsoft accounts. See console for details.");
          }
          
          throw new Error(`HTTP error! status: ${response.status}, body: ${errorText}`);
        }
        
        const data = await response.json();
        console.error(`Response received: ${JSON.stringify(data).substring(0, 200)}...`);
        return data as T;
      } catch (error) {
        console.error("Error making Graph API request:", error);
        return null;
      }
  • Helper function getAccessToken used by the handler to obtain a valid access token, handling refresh if necessary.
    async function getAccessToken(): Promise<string | null> {
      try {
        console.error('getAccessToken called');
        
        // First check if we have a valid current access token in memory
        if (currentAccessToken) {
          return currentAccessToken;
        }
        
        // Check for tokens in environment variables or file
        try {
          // Read token file
          const tokenData = readTokens();
          
          if (tokenData) {
            // Check if token is expired
            const now = Date.now();
            if (now > tokenData.expiresAt) {
              console.error(`Token is expired. Current time: ${now}, expires at: ${tokenData.expiresAt}`);
              
              // If we have a refresh token, try to refresh the access token
              if (tokenData.refreshToken || currentRefreshToken) {
                console.error('Attempting to refresh token...');
                const refreshTokenToUse = currentRefreshToken || tokenData.refreshToken;
                const newTokenData = await refreshAccessToken(refreshTokenToUse);
                if (newTokenData) {
                  console.error('Token refreshed successfully');
                  return newTokenData.accessToken;
                }
                console.error('Token refresh failed');
              }
              
              return null;
            }
            
            // Success - return the token and update current state
            currentAccessToken = tokenData.accessToken;
            currentRefreshToken = tokenData.refreshToken;
            console.error(`Successfully retrieved valid token (${tokenData.accessToken.substring(0, 10)}...)`);
            return tokenData.accessToken;
          }
        } catch (readError) {
          console.error(`Direct token read error: ${readError}`);
          return null;
        }
        
        return null;
      } catch (error) {
        console.error("Error getting access token:", error);
        return null;
      }
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A3.7/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the burden of behavioral disclosure. It does clarify the deletion scope (only the subtask), which is useful, but it fails to mention that deletion is permanent, what happens to the parent task, or any required permissions. This leaves important behavioral aspects undisclosed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two short sentences, front-loaded with the action and resource. Every word contributes value—the first sentence states the core function, and the second clarifies the precise scope. There is no fluff or repetition.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simplicity of the operation (delete a single checklist item) and full schema coverage, the description covers the essential purpose and scope. However, since no output schema is provided, it does not explain the expected response or side effects, leaving the agent to infer behavior. A brief note on success/failure or irreversibility would improve completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema provides descriptions for all three parameters, achieving 100% coverage. The tool description does not add any additional parameter-level meaning beyond the schema, so a baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb ('Delete') and names the exact resource ('checklist item (subtask)'), clearly distinguishing it from sibling tools like delete-task and delete-task-list. The added clarification that it only removes the subtask, not the parent task, further disambiguates its scope.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context by stating what is deleted and the scope caveat ('not the parent task'), which implicitly guides the user. However, it does not explicitly mention when to use this tool versus alternatives like update-checklist-item, nor does it state when not to use it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.