getTaskById
Retrieve a specific task by its unique ID using Teamwork MCP server. Input the task ID to access detailed task information directly from the Teamwork API.
Instructions
Get a specific task by ID from Teamwork
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| taskId | Yes | The ID of the task to retrieve |
Implementation Reference
- src/tools/tasks/getTaskById.ts:32-59 (handler)The handler function that implements the core logic of the getTaskById tool. It processes input, calls the teamwork service to fetch the task, formats the response, and handles errors.export async function handleGetTaskById(input: any) { logger.info('Calling teamworkService.getTaskById()'); logger.info(`Task ID: ${input?.taskId}`); try { const taskId = String(input?.taskId); if (!taskId) { throw new Error("Task ID is required"); } const task = await teamworkService.getTaskById(taskId); return { content: [{ type: "text", text: JSON.stringify(task, null, 2) }] }; } catch (error: any) { logger.error(`Error in getTaskById handler: ${error.message}`); return { content: [{ type: "text", text: `Error retrieving task: ${error.message}` }] }; } }
- src/tools/tasks/getTaskById.ts:10-29 (schema)The tool definition including name, description, input schema (requiring taskId as integer), and annotations.export const getTaskByIdDefinition = { name: "getTaskById", description: "Get a specific task by ID from Teamwork", inputSchema: { type: "object", properties: { taskId: { type: "integer", description: "The ID of the task to retrieve" } }, required: ["taskId"] }, annotations: { title: "Get a Task by its ID", readOnlyHint: false, destructiveHint: false, openWorldHint: false } };
- src/tools/index.ts:73-73 (registration)Registration of the getTaskById tool in the central toolPairs array, pairing its definition and handler for use in toolDefinitions and toolHandlersMap.{ definition: getTaskById, handler: handleGetTaskById },
- Supporting service function that performs the actual API call to retrieve the task by ID from Teamwork, used by the tool handler.export const getTaskById = async (taskId: string) => { try { const api = ensureApiClient(); const response = await api.get(`/tasks/${taskId}.json`); return response.data; } catch (error: any) { logger.error(`Error fetching task ${taskId}: ${error.message}`); throw new Error(`Failed to fetch task ${taskId}`); } };