Skip to main content
Glama
robertn702

Sunsama MCP Server

get-task-by-id

Retrieve a specific task from Sunsama using its unique ID to access detailed task information and manage individual task data.

Instructions

Get a specific task by its ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
taskIdYesThe ID of the task to retrieve

Implementation Reference

  • The core handler for the 'get-task-by-id' tool, which fetches the task using the Sunsama client and returns a formatted JSON response.
    export const getTaskByIdTool = withTransportClient({
      name: "get-task-by-id",
      description: "Get a specific task by its ID",
      parameters: getTaskByIdSchema,
      execute: async ({ taskId }: GetTaskByIdInput, context: ToolContext) => {
        const task = await context.client.getTaskById(taskId) || null;
    
        return formatJsonResponse(task);
      },
    });
  • Zod schema validating the input parameters for the tool (requires a non-empty taskId string).
    export const getTaskByIdSchema = z.object({
      taskId: z.string().min(1, "Task ID is required").describe(
        "The ID of the task to retrieve",
      ),
    });
  • Registration of the getTaskByIdTool within the taskTools array, which is imported and aggregated into allTools for MCP server registration.
    export const taskTools = [
      // Query tools
      getTasksBacklogTool,
      getTasksByDayTool,
      getArchivedTasksTool,
      getTaskByIdTool,
    
      // Lifecycle tools
      createTaskTool,
      deleteTaskTool,
    
      // Update tools
      updateTaskCompleteTool,
      updateTaskSnoozeDateTool,
      updateTaskBacklogTool,
      updateTaskPlannedTimeTool,
      updateTaskNotesTool,
      updateTaskDueDateTool,
      updateTaskTextTool,
      updateTaskStreamTool,
    ];
  • src/tools/index.ts:1-9 (registration)
    Aggregates taskTools (including get-task-by-id) into allTools for final server registration.
    import { userTools } from "./user-tools.js";
    import { taskTools } from "./task-tools.js";
    import { streamTools } from "./stream-tools.js";
    
    export const allTools = [
      ...userTools,
      ...taskTools,
      ...streamTools,
    ];
  • src/main.ts:33-44 (registration)
    Final MCP server registration loop that registers the 'get-task-by-id' tool from allTools.
    allTools.forEach((tool) => {
      server.registerTool(
        tool.name,
        {
          description: tool.description,
          inputSchema: "shape" in tool.parameters
            ? tool.parameters.shape
            : tool.parameters,
        },
        tool.execute,
      );
    });
  • Helper function used by the handler to format the task response as MCP-compliant JSON text content.
    export function formatJsonResponse(data: any) {
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(data, null, 2),
          },
        ],
      };
    }

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/robertn702/mcp-sunsama'

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