Skip to main content
Glama

google_tasks_get_task

Retrieve specific task details by providing the task ID and optional task list ID from Google Tasks. Integrates with Google MCP for AI client compatibility.

Instructions

Get details about a specific task

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
taskIdYesID of the task to retrieve
taskListIdNoID of the task list the task belongs to (uses default if not specified)

Implementation Reference

  • Main handler function for 'google_tasks_get_task' tool. Validates input arguments, extracts taskId and taskListId, calls the GoogleTasks instance's getTask method, and formats the response.
    export async function handleTasksGetTask(
      args: any,
      googleTasksInstance: GoogleTasks
    ) {
      if (!isGetTaskArgs(args)) {
        throw new Error("Invalid arguments for google_tasks_get_task");
      }
      const { taskId, taskListId } = args;
      const result = await googleTasksInstance.getTask(taskId, taskListId);
      return {
        content: [{ type: "text", text: result }],
        isError: false,
      };
    }
  • Tool definition including name, description, and inputSchema for 'google_tasks_get_task'.
    export const GET_TASK_TOOL: Tool = {
      name: "google_tasks_get_task",
      description: "Get details about a specific task",
      inputSchema: {
        type: "object",
        properties: {
          taskId: {
            type: "string",
            description: "ID of the task to retrieve",
          },
          taskListId: {
            type: "string",
            description:
              "ID of the task list the task belongs to (uses default if not specified)",
          },
        },
        required: ["taskId"],
      },
    };
  • Registration in the switch statement that dispatches tool calls to the specific handler function.
    case "google_tasks_get_task":
      return await tasksHandlers.handleTasksGetTask(
        args,
        googleTasksInstance
      );
  • Type guard function used for input validation in the handler (isGetTaskArgs).
    export function isGetTaskArgs(args: any): args is {
      taskId: string;
      taskListId?: string;
    } {
      return (
        args &&
        typeof args.taskId === "string" &&
        (args.taskListId === undefined || typeof args.taskListId === "string")
      );
    }
  • Core implementation in GoogleTasks class: fetches the task using Google API, formats the output with title, ID, status, due date, completion date, and notes.
      async getTask(taskId: string, taskListId?: string) {
        try {
          const targetTaskList = taskListId || this.defaultTaskList;
          const response = await this.tasks.tasks.get({
            tasklist: targetTaskList,
            task: taskId,
          });
    
          const task = response.data;
          const due = task.due ? `Due: ${new Date(task.due).toLocaleString()}` : "";
          const completed = task.completed
            ? `Completed: ${new Date(task.completed).toLocaleString()}`
            : "";
          const status = task.status || "";
    
          return `Task: ${task.title}
    ID: ${task.id}
    Status: ${status}
    ${due}
    ${completed}
    ${task.notes ? `Notes: ${task.notes}` : ""}`;
        } catch (error) {
          throw new Error(
            `Failed to get task: ${
              error instanceof Error ? error.message : String(error)
            }`
          );
        }
      }

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/vakharwalad23/google-mcp'

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