Skip to main content
Glama
arpitbatra123

Google Tasks MCP Server

move-task

Change task order in Google Tasks by moving a task to a new position within a list, optionally setting parent tasks or sibling order.

Instructions

Move a task to another position

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tasklistYesTask list ID
taskYesTask ID to move
parentNoOptional new parent task ID
previousNoOptional previous sibling task ID

Implementation Reference

  • Handler function that checks authentication, constructs move parameters, calls Google Tasks API's move method, and returns success or error response.
    async ({ tasklist, task, parent, previous }) => {
      if (!isAuthenticated()) {
        return {
          isError: true,
          content: [
            {
              type: "text",
              text: "Not authenticated. Please use the 'authenticate' tool first.",
            },
          ],
        };
      }
    
      try {
        const moveParams: any = {
          tasklist,
          task,
        };
    
        if (parent !== undefined) moveParams.parent = parent;
        if (previous !== undefined) moveParams.previous = previous;
    
        const response = await tasks.tasks.move(moveParams);
    
        return {
          content: [
            {
              type: "text",
              text: `Task moved successfully:\n\n${JSON.stringify(
                response.data,
                null,
                2
              )}`,
            },
          ],
        };
      } catch (error) {
        console.error("Error moving task:", error);
        return {
          isError: true,
          content: [
            {
              type: "text",
              text: `Error moving task: ${error}`,
            },
          ],
        };
      }
    }
  • Zod schema defining input parameters for the move-task tool: required tasklist and task IDs, optional parent and previous sibling IDs.
      tasklist: z.string().describe("Task list ID"),
      task: z.string().describe("Task ID to move"),
      parent: z.string().optional().describe("Optional new parent task ID"),
      previous: z
        .string()
        .optional()
        .describe("Optional previous sibling task ID"),
    },
  • src/index.ts:858-919 (registration)
    Registration of the 'move-task' tool on the MCP server with name, description, input schema, and handler function.
    server.tool(
      "move-task",
      "Move a task to another position",
      {
        tasklist: z.string().describe("Task list ID"),
        task: z.string().describe("Task ID to move"),
        parent: z.string().optional().describe("Optional new parent task ID"),
        previous: z
          .string()
          .optional()
          .describe("Optional previous sibling task ID"),
      },
      async ({ tasklist, task, parent, previous }) => {
        if (!isAuthenticated()) {
          return {
            isError: true,
            content: [
              {
                type: "text",
                text: "Not authenticated. Please use the 'authenticate' tool first.",
              },
            ],
          };
        }
    
        try {
          const moveParams: any = {
            tasklist,
            task,
          };
    
          if (parent !== undefined) moveParams.parent = parent;
          if (previous !== undefined) moveParams.previous = previous;
    
          const response = await tasks.tasks.move(moveParams);
    
          return {
            content: [
              {
                type: "text",
                text: `Task moved successfully:\n\n${JSON.stringify(
                  response.data,
                  null,
                  2
                )}`,
              },
            ],
          };
        } catch (error) {
          console.error("Error moving task:", error);
          return {
            isError: true,
            content: [
              {
                type: "text",
                text: `Error moving task: ${error}`,
              },
            ],
          };
        }
      }
    );
  • Helper function used in the handler to check if the user is authenticated by verifying if credentials are set.
    function isAuthenticated() {
      return credentials !== null;
    }
  • Initialization of the Google Tasks API client used by the handler to call the move method.
    const tasks = google.tasks({ version: 'v1', auth: oauth2Client });

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