getTaskListsByProjectId
Retrieve all task lists for a specific project in Teamwork to organize and track project tasks effectively.
Instructions
Get all task lists by project ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | The ID of the project to get task lists from |
Implementation Reference
- The main MCP tool handler function. Validates projectId from input, calls the teamwork service to fetch task lists, formats the response as text content, and handles errors.export async function handleGetTaskListsByProjectId(input: any) { logger.info('Calling teamworkService.getTaskListsByProjectId()'); logger.info(`Project ID: ${input?.projectId}`); try { const projectId = input?.projectId; if (!projectId) { throw new Error("Project ID is required"); } const taskLists = await teamworkService.getTaskListsByProjectId(projectId); logger.info(`Task lists response received for project ID: ${projectId}`); if (taskLists) { return { content: [{ type: "text", text: JSON.stringify(taskLists, null, 2) }] }; } else { return { content: [{ type: "text", text: `Error getting task lists for project ID: ${projectId}` }] }; } } catch (error: any) { return createErrorResponse(error, 'Retrieving task lists'); } }
- The tool schema definition, including name, description, input schema requiring projectId (integer), and annotations.export const getTaskListsByProjectIdDefinition = { name: "getTaskListsByProjectId", description: "Get all task lists by project ID", inputSchema: { type: "object", properties: { projectId: { type: "integer", description: "The ID of the project to get task lists from" } }, required: ["projectId"] }, annotations: { title: "Get Task Lists by Project ID", readOnlyHint: false, destructiveHint: false, openWorldHint: false } };
- src/tools/index.ts:71-71 (registration)Registration of the tool in the toolPairs array, pairing the definition with its handler function.{ definition: getTaskListsByProjectId, handler: handleGetTaskListsByProjectId },
- src/tools/index.ts:15-15 (registration)Import statement bringing in the tool definition (aliased) and handler from the specific tool file.import { getTaskListsByProjectIdDefinition as getTaskListsByProjectId, handleGetTaskListsByProjectId } from './tasks/getTaskListsByProjectId.js';
- Supporting service function called by the handler. Performs the actual API request to Teamwork to retrieve task lists for the given project ID.export const getTaskListsByProjectId = async (projectId: number) => { try { const api = ensureApiClient(); const response = await api.get(`/projects/${projectId}/tasklists.json`); return response.data; } catch (error: any) { logger.error(`Error fetching task lists for project ${projectId}: ${error.message}`); throw new Error(`Failed to fetch task lists for project ${projectId}`); } };