getTaskSubtasks
Retrieve all subtasks for a given task in Teamwork, with pagination support and optional inclusion of completed tasks.
Instructions
Get all subtasks for a specific task in Teamwork
Input 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 main handler function that executes the 'getTaskSubtasks' tool logic. It accepts an input object containing taskId (required), page, pageSize, and includeCompletedTasks, makes a GET request to /tasks/{taskId}/subtasks.json via the Teamwork API client, and returns the subtasks data.
// Tool handler 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/input schema for 'getTaskSubtasks'. It specifies the tool name, description, and input schema properties: taskId (required integer), page (integer), pageSize (integer), and includeCompletedTasks (boolean). Also includes annotations for the tool.
// Tool definition 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:23-23 (registration)The import of the getTaskSubtasks definition and handler from the getTaskSubtasks module into the tools index.
import { getTaskSubtasksDefinition as getTaskSubtasks, handleGetTaskSubtasks } from './tasks/getTaskSubtasks.js'; - src/tools/index.ts:80-80 (registration)Registration of the getTaskSubtasks tool pair (definition + handler) in the toolPairs array within the tools index.
{ definition: getTaskSubtasks, handler: handleGetTaskSubtasks }, - src/utils/config.ts:249-257 (registration)Configuration file where 'getTaskSubtasks' is listed as one of the available tools under the 'Tasks' group.
const toolGroups: Record<string, string[]> = { 'Projects': ['getProjects', 'getCurrentProject', 'createProject'], 'Tasks': ['getTasks', 'getTasksByProjectId', 'getTaskListsByProjectId', 'getTaskById', 'createTask', 'createSubTask', 'updateTask', 'deleteTask', 'getTasksMetricsComplete', 'getTasksMetricsLate', 'getTaskSubtasks', 'getTaskComments'], 'People': ['getPeople', 'getPersonById', 'getProjectPeople', 'addPeopleToProject', 'deletePerson', 'getProjectsPeopleMetricsPerformance', 'getProjectsPeopleUtilization', 'getProjectPerson'], 'Reporting': ['getProjectsReportingUserTaskCompletion', 'getProjectsReportingUtilization'], 'Time': ['getTime', 'getProjectsAllocationsTime', 'getTimezones'], 'Comments': ['createComment'], 'Companies': ['createCompany', 'updateCompany', 'deleteCompany', 'getCompanies', 'getCompanyById'] };