create-task
Add a new task to Google Tasks with title, notes, and due date through Claude's interface.
Instructions
Create a new task in a task list
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tasklist | Yes | Task list ID | |
| title | Yes | Title of the task | |
| notes | No | Notes for the task | |
| due | No | Due date in RFC 3339 format (e.g., 2025-03-19T12:00:00Z) |
Implementation Reference
- src/index.ts:604-655 (handler)The asynchronous handler function that implements the 'create-task' tool logic. It checks authentication, constructs the task request body, inserts the task via the Google Tasks API, and handles success/error responses.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 schema defining the input parameters for the 'create-task' tool: tasklist (required string), title (required string), notes (optional string), due (optional string in RFC 3339 format).{ 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-656 (registration)The server.tool() call that registers the 'create-task' tool with its name, description, input schema, and handler function.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}`, }, ], }; } } );