getTaskById
Retrieve a specific task from Teamwork using its unique identifier. Get task details directly to integrate project data into your workflow.
Instructions
Get a specific task by ID from Teamwork
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| taskId | Yes | The ID of the task to retrieve |
Implementation Reference
- src/tools/tasks/getTaskById.ts:33-54 (handler)Tool handler that receives the input, extracts taskId, calls the service, and returns the task data as JSON string content.
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 'getTaskById', description, inputSchema (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 getTaskById tool in the toolPairs array, pairing its definition with the handler.
{ definition: getTaskById, handler: handleGetTaskById }, - Service layer function that makes the actual API call to GET /tasks/{taskId}.json via the API client.
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}`); } }; - src/utils/config.ts:251-251 (registration)Tool group mapping in config that includes 'getTaskById' under the 'Tasks' group for allow/deny list filtering.
'Tasks': ['getTasks', 'getTasksByProjectId', 'getTaskListsByProjectId', 'getTaskById', 'createTask', 'createSubTask', 'updateTask', 'deleteTask', 'getTasksMetricsComplete', 'getTasksMetricsLate', 'getTaskSubtasks', 'getTaskComments'],