create_task
Add a new task to Google Tasks by specifying a title and optional notes, enabling efficient task management and organization.
Instructions
Create a new task in Google Tasks
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| notes | No | Notes for the task | |
| title | Yes | Title of the task |
Implementation Reference
- src/index.ts:211-243 (handler)The execution handler for the 'create_task' tool within the CallToolRequestSchema handler. It validates the input arguments, calls the Google Tasks API to insert a new task into the default tasklist, and returns the created task data.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 in the ListToolsRequestSchema handler, including its name, description, and 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:145-152 (schema)JSON Schema definition for the input arguments of the 'create_task' tool.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 expected arguments for create_task.interface CreateTaskArgs { title: string; notes?: string; taskId?: string; status?: string; }
- src/index.ts:43-53 (helper)Type guard function used to validate CreateTaskArgs in the handler.// Type guard for CreateTaskArgs 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") ); }