Skip to main content
Glama
arpitbatra123

Google Tasks MCP Server

complete-task

Mark tasks as completed in Google Tasks to track progress and manage task lists through Claude.

Instructions

Mark a task as completed

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tasklistYesTask list ID
taskYesTask ID to mark as completed

Implementation Reference

  • Handler function that authenticates the user, fetches the task, updates its status to 'completed' with a timestamp, and returns the updated task details or an error.
    async ({ tasklist, task }) => {
      if (!isAuthenticated()) {
        return {
          isError: true,
          content: [
            {
              type: "text",
              text: "Not authenticated. Please use the 'authenticate' tool first.",
            },
          ],
        };
      }
    
      try {
        // Get the current task
        const currentTask = await tasks.tasks.get({
          tasklist,
          task,
        });
    
        // Update the status to completed
        const requestBody = {
          ...currentTask.data,
          status: "completed",
          completed: new Date().toISOString(),
        };
    
        const response = await tasks.tasks.update({
          tasklist,
          task,
          requestBody,
        });
    
        return {
          content: [
            {
              type: "text",
              text: `Task marked as completed:\n\n${JSON.stringify(
                response.data,
                null,
                2
              )}`,
            },
          ],
        };
      } catch (error) {
        console.error("Error completing task:", error);
        return {
          isError: true,
          content: [
            {
              type: "text",
              text: `Error completing task: ${error}`,
            },
          ],
        };
      }
    }
  • Zod schema defining input parameters: tasklist ID and task ID.
    {
      tasklist: z.string().describe("Task list ID"),
      task: z.string().describe("Task ID to mark as completed"),
    },
  • src/index.ts:790-855 (registration)
    Registration of the 'complete-task' tool using server.tool, including name, description, input schema, and handler function.
    server.tool(
      "complete-task",
      "Mark a task as completed",
      {
        tasklist: z.string().describe("Task list ID"),
        task: z.string().describe("Task ID to mark as completed"),
      },
      async ({ tasklist, task }) => {
        if (!isAuthenticated()) {
          return {
            isError: true,
            content: [
              {
                type: "text",
                text: "Not authenticated. Please use the 'authenticate' tool first.",
              },
            ],
          };
        }
    
        try {
          // Get the current task
          const currentTask = await tasks.tasks.get({
            tasklist,
            task,
          });
    
          // Update the status to completed
          const requestBody = {
            ...currentTask.data,
            status: "completed",
            completed: new Date().toISOString(),
          };
    
          const response = await tasks.tasks.update({
            tasklist,
            task,
            requestBody,
          });
    
          return {
            content: [
              {
                type: "text",
                text: `Task marked as completed:\n\n${JSON.stringify(
                  response.data,
                  null,
                  2
                )}`,
              },
            ],
          };
        } catch (error) {
          console.error("Error completing task:", error);
          return {
            isError: true,
            content: [
              {
                type: "text",
                text: `Error completing task: ${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/arpitbatra123/mcp-googletasks'

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