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
| Name | Required | Description | Default |
|---|---|---|---|
| tasklist | Yes | Task list ID | |
| task | Yes | Task ID to move | |
| parent | No | Optional new parent task ID | |
| previous | No | Optional previous sibling task ID |
Implementation Reference
- src/index.ts:870-918 (handler)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}`, }, ], }; } }
- src/index.ts:862-869 (schema)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}`, }, ], }; } } );
- src/index.ts:47-49 (helper)Helper function used in the handler to check if the user is authenticated by verifying if credentials are set.function isAuthenticated() { return credentials !== null; }
- src/index.ts:41-42 (helper)Initialization of the Google Tasks API client used by the handler to call the move method.const tasks = google.tasks({ version: 'v1', auth: oauth2Client });