getTaskSubtasks
Retrieve all subtasks for a specific Teamwork task, including pagination options and completed task filtering.
Instructions
Get all subtasks for a specific task in Teamwork
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| taskId | Yes | The ID of the task to get subtasks from | |
| page | No | Page number for pagination | |
| pageSize | No | Number of items per page | |
| includeCompletedTasks | No | Include completed tasks in the results |
Implementation Reference
- The handler function that implements the core logic of the 'getTaskSubtasks' tool. It extracts input parameters, builds query params, calls the Teamwork API to fetch subtasks for the given taskId, and returns the response or handles errors.export async function handleGetTaskSubtasks(input: any) { try { const { taskId, page, pageSize, includeCompletedTasks, ...otherParams } = input; logger.info(`Getting subtasks for task ID: ${taskId}`); // Build query parameters const queryParams: Record<string, any> = { page, pageSize, includeCompletedTasks, ...otherParams }; // Filter out undefined values Object.keys(queryParams).forEach(key => queryParams[key] === undefined && delete queryParams[key] ); // Make API call const apiClient = getApiClientForVersion(); const response = await apiClient.get( `/tasks/${taskId}/subtasks.json`, { params: queryParams } ); return { content: [{ type: "text", text: JSON.stringify(response.data, null, 2) }] }; } catch (error: any) { return createErrorResponse(error, 'Retrieving task subtasks'); } }
- The tool definition including name, description, input schema (with required taskId and optional pagination params), and annotations for the 'getTaskSubtasks' tool.export const getTaskSubtasksDefinition = { name: "getTaskSubtasks", description: "Get all subtasks for a specific task in Teamwork", inputSchema: { type: "object", properties: { taskId: { type: "integer", description: "The ID of the task to get subtasks from" }, page: { type: "integer", description: "Page number for pagination" }, pageSize: { type: "integer", description: "Number of items per page" }, includeCompletedTasks: { type: "boolean", description: "Include completed tasks in the results" } }, required: ["taskId"] }, annotations: { title: "Get Task Subtasks", readOnlyHint: false, destructiveHint: false, openWorldHint: false } };
- src/tools/index.ts:79-80 (registration)Registration of the 'getTaskSubtasks' tool in the central toolPairs array, pairing its definition and handler for use in toolDefinitions and toolHandlersMap.{ definition: getTasksMetricsLate, handler: handleGetTasksMetricsLate }, { definition: getTaskSubtasks, handler: handleGetTaskSubtasks },
- src/tools/index.ts:128-128 (registration)Re-export of the handleGetTaskSubtasks handler from the index file for convenient access.export { handleGetTaskSubtasks } from './tasks/getTaskSubtasks.js';
- src/tools/index.ts:23-23 (registration)Import of the getTaskSubtasks definition and handler into the central index file.import { getTaskSubtasksDefinition as getTaskSubtasks, handleGetTaskSubtasks } from './tasks/getTaskSubtasks.js';