create-task
Add new tasks to Google Tasks by specifying a task list ID, title, optional notes, and due date. Streamline task management directly through the MCP server interface.
Instructions
Create a new task in a task list
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| due | No | Due date in RFC 3339 format (e.g., 2025-03-19T12:00:00Z) | |
| notes | No | Notes for the task | |
| tasklist | Yes | Task list ID | |
| title | Yes | Title of the task |
Implementation Reference
- src/index.ts:604-656 (handler)The handler function that checks authentication, prepares the task request body, calls the Google Tasks API to insert the task, and returns the result or error.async ({ tasklist, title, notes, due }) => { if (!isAuthenticated()) { return { isError: true, content: [ { type: "text", text: "Not authenticated. Please use the 'authenticate' tool first.", }, ], }; } try { const requestBody: any = { title, status: "needsAction", }; if (notes) requestBody.notes = notes; if (due) requestBody.due = due; const response = await tasks.tasks.insert({ tasklist, requestBody, }); return { content: [ { type: "text", text: `Task created successfully:\n\n${JSON.stringify( response.data, null, 2 )}`, }, ], }; } catch (error) { console.error("Error creating task:", error); return { isError: true, content: [ { type: "text", text: `Error creating task: ${error}`, }, ], }; } } );
- src/index.ts:595-603 (schema)Zod input schema defining parameters for creating a task: required tasklist and title, optional notes and due date.{ tasklist: z.string().describe("Task list ID"), title: z.string().describe("Title of the task"), notes: z.string().optional().describe("Notes for the task"), due: z .string() .optional() .describe("Due date in RFC 3339 format (e.g., 2025-03-19T12:00:00Z)"), },
- src/index.ts:592-657 (registration)The server.tool registration call that defines the tool name, description, input schema, and handler function for the 'create-task' tool.server.tool( "create-task", "Create a new task in a task list", { tasklist: z.string().describe("Task list ID"), title: z.string().describe("Title of the task"), notes: z.string().optional().describe("Notes for the task"), due: z .string() .optional() .describe("Due date in RFC 3339 format (e.g., 2025-03-19T12:00:00Z)"), }, async ({ tasklist, title, notes, due }) => { if (!isAuthenticated()) { return { isError: true, content: [ { type: "text", text: "Not authenticated. Please use the 'authenticate' tool first.", }, ], }; } try { const requestBody: any = { title, status: "needsAction", }; if (notes) requestBody.notes = notes; if (due) requestBody.due = due; const response = await tasks.tasks.insert({ tasklist, requestBody, }); return { content: [ { type: "text", text: `Task created successfully:\n\n${JSON.stringify( response.data, null, 2 )}`, }, ], }; } catch (error) { console.error("Error creating task:", error); return { isError: true, content: [ { type: "text", text: `Error creating task: ${error}`, }, ], }; } } );