create_task
Add new tasks to Google Tasks with titles and optional notes to organize your to-do list.
Instructions
Create a new task in Google Tasks
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes | Title of the task | |
| notes | No | Notes for the task |
Implementation Reference
- src/index.ts:211-243 (handler)Handler for the 'create_task' tool in the CallToolRequestSchema. Validates input with isValidCreateTaskArgs and inserts a new task into Google Tasks using the API.if (request.params.name === "create_task") { if (!isValidCreateTaskArgs(request.params.arguments)) { throw new McpError( ErrorCode.InvalidParams, "Invalid arguments for creating a task. 'title' must be a string, and 'notes' must be a string or undefined." ); } const args = request.params.arguments; try { const response = await tasks.tasks.insert({ tasklist: "@default", requestBody: { title: args.title, notes: args.notes, }, }); return { content: [ { type: "text", text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { throw new McpError( ErrorCode.InternalError, `Tasks API error: ${error}` ); } }
- src/index.ts:142-153 (registration)Registration of the 'create_task' tool within the ListToolsRequestSchema handler, including name, description, and JSON input schema.{ name: "create_task", description: "Create a new task in Google Tasks", inputSchema: { type: "object", properties: { title: { type: "string", description: "Title of the task" }, notes: { type: "string", description: "Notes for the task" }, }, required: ["title"], }, },
- src/index.ts:36-41 (schema)TypeScript interface defining the structure of CreateTaskArgs for type safety.interface CreateTaskArgs { title: string; notes?: string; taskId?: string; status?: string; }
- src/index.ts:44-53 (helper)Type guard helper function to validate if arguments match CreateTaskArgs interface, used in the handler.export function isValidCreateTaskArgs(args: any): args is CreateTaskArgs { return ( typeof args === "object" && args !== null && (args.title === undefined || typeof args.title === "string") && (args.notes === undefined || typeof args.notes === "string") && (args.taskId === undefined || typeof args.taskId === "string") && (args.status === undefined || typeof args.status === "string") ); }