getTaskListsByProjectId
Retrieve all task lists associated with a specific project ID using the Teamwork MCP server to streamline project management workflows.
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 tool handler that processes the input, calls the teamworkService.getTaskListsByProjectId service, formats the response as JSON 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) { logger.error(`Error in getTaskListsByProjectId handler: ${error.message}`); return { content: [{ type: "text", text: `Error retrieving task lists: ${error.message}` }] }; } }
- The tool definition including name, description, input schema requiring projectId as 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 and handler for inclusion in toolDefinitions and toolHandlersMap.{ definition: getTaskListsByProjectId, handler: handleGetTaskListsByProjectId },
- Helper service function that makes the API call to retrieve task lists for a given project ID from Teamwork API.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}`); } };
- src/tools/index.ts:15-15 (registration)Import of the tool definition and handler from the specific tasks file.import { getTaskListsByProjectIdDefinition as getTaskListsByProjectId, handleGetTaskListsByProjectId } from './tasks/getTaskListsByProjectId.js';