getTaskById
Retrieve a specific task from Teamwork projects using its unique ID to access detailed information and manage project workflows.
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:33-54 (handler)MCP tool handler function that validates input, calls the teamwork service to fetch the task, formats the response as text content, 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) { return createErrorResponse(error, 'Retrieving task'); } }
- src/tools/tasks/getTaskById.ts:11-30 (schema)Tool definition including name, description, input schema (taskId as integer), and annotations for the MCP tool.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 toolPairs array, mapping definition to handler for MCP tool registry.{ definition: getTaskById, handler: handleGetTaskById },
- Service function that performs the actual API call to Teamwork to retrieve a task by ID, 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}`); } };