Skip to main content
Glama
mstfe

Google Tasks MCP Server

by mstfe

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
NameRequiredDescriptionDefault
titleYesTitle of the task
notesNoNotes for the task

Implementation Reference

  • 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"],
      },
    },
  • TypeScript interface defining the structure of CreateTaskArgs for type safety.
    interface CreateTaskArgs {
      title: string;
      notes?: string;
      taskId?: string;
      status?: string;
    }
  • 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")
      );
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mstfe/mcp-google-tasks'

If you have feedback or need assistance with the MCP directory API, please join our Discord server