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
| Name | Required | Description | Default |
|---|---|---|---|
| taskId | Yes | The ID of the task to retrieve |
Implementation Reference
- src/tools/task-tools.ts:107-116 (handler)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); }, });
- src/schemas.ts:42-46 (schema)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", ), });
- src/tools/task-tools.ts:406-426 (registration)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, ); });
- src/tools/shared.ts:70-79 (helper)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), }, ], }; }