getTasks
Retrieve multiple tasks with optional filters such as date range, priority, status, project, and assignee. Use to manage and report on task data.
Instructions
Get tasks, Return multiple tasks according to the optional provided filter.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| updatedBefore | No | filter by updated before date | |
| updatedAfter | No | filter by updated after date | |
| today | No | filter by today | |
| taskFilter | No | filter by a taskFilter | |
| startDate | No | filter on start date | |
| searchTerm | No | filter by search term | |
| reportType | No | define the type of the report | |
| reportFormat | No | define the format of the report | |
| priority | No | filter by task priority | |
| orderMode | No | order mode | |
| orderBy | No | order by | |
| notCompletedBefore | No | filter by projects that have not been completed before the given date | |
| endDate | No | filter on end date | |
| dueBefore | No | filter before a due date | |
| dueAfter | No | filter after a due date | |
| deletedAfter | No | filter on deleted after date | |
| createdFilter | No | filter by created filter | |
| createdDateCode | No | filter by created date code | |
| createdBefore | No | filter by created before date | |
| createdAfter | No | filter by created after date | |
| completedBefore | No | filter by completed before date | |
| completedAfter | No | filter by completed after date | |
| updatedByUserId | No | filter by updated user id | |
| parentTaskId | No | filter by parent task ids | |
| pageSize | No | number of items in a page | |
| page | No | page number | |
| orderByCustomFieldId | No | order by custom field id when orderBy is equal to custom field | |
| includeTaskId | No | include task id | |
| filterId | No | provide a user saved filter ID | |
| completedByUserId | No | filter by completed user id | |
| useTaskDateRange | No | use date range logic from table when getting the tasks | |
| useStartDatesForTodaysTasks | No | use start dates for todays tasks | |
| useFormulaFields | No | use formula fields | |
| useAllProjects | No | filter on all projects | |
| sortActiveFirst | No | sort active tasks first | |
| skipCounts | No | Skip counts allows you to skip doing counts on a list API endpoint for performance reasons. | |
| showDeleted | No | include deleted items | |
| showCompletedLists | No | include tasks from completed lists | |
| searchCompaniesTeams | No | include companies and teams in the search term | |
| searchAssignees | No | include assignees in the search | |
| onlyUntaggedTasks | No | only untagged tasks | |
| onlyUnplanned | No | only return tasks that are unplanned. Not assigned, no due date or missing estimated time. | |
| onlyTasksWithUnreadComments | No | filter by only tasks with unread comments | |
| onlyTasksWithTickets | No | filter by only tasks with tickets | |
| onlyTasksWithEstimatedTime | No | only return tasks with estimated time | |
| onlyStarredProjects | No | filter by starred projects only | |
| onlyAdminProjects | No | only include tasks from projects where the user is strictly a project admin. site admins have visibility to all projects. | |
| nestSubTasks | No | nest sub tasks | |
| matchAllTags | No | match all tags | |
| matchAllProjectTags | No | match all project tags | |
| matchAllExcludedTags | No | match all exclude tags | |
| isReportDownload | No | generate a report export. | |
| includeUpdate | No | include tasks latest update action | |
| includeUntaggedTasks | No | include untagged tasks | |
| includeTomorrow | No | filter by include tomorrow | |
| includeToday | No | filter by include today | |
| includeTeamUserIds | No | include members of the given teams | |
| includeTasksWithoutDueDates | No | include tasks without due dates | |
| includeTasksWithCards | No | include tasks with cards | |
| includeTasksFromDeletedLists | No | include tasks from deleted lists | |
| includeTasksCount | No | include total count of tasks for given filter | |
| includeRelatedTasks | No | include ids of active subtasks, dependencies, predecessors | |
| includePrivateItems | No | include private items | |
| includeOverdueTasks | No | include overdue tasks | |
| includeOriginalDueDate | No | include original due date of a task | |
| includeCustomFields | No | include custom fields | |
| includeCompletedTasks | No | include completed tasks | |
| includeCompletedPredecessors | No | include ids of completed predecessors. It must be provided with includeRelatedTasks flag or with the predecessors sideload. | |
| includeCompanyUserIds | No | include members of the given companies | |
| includeCommentStats | No | include number of unread and read comments for each task | |
| includeBlocked | No | filter by include blocked | |
| includeAttachmentCommentStats | No | include number of unread and read comments for each file attachment | |
| includeAssigneeTeams | No | include teams related to the responsible user ids | |
| includeAssigneeCompanies | No | include companies related to the responsible user ids | |
| includeArchivedProjects | No | include archived projects | |
| includeAllComments | No | include all comments | |
| groupByTasklist | No | group by tasklist | |
| groupByTaskgroup | No | group by taskgroup | |
| getSubTasks | No | get sub tasks | |
| getFiles | No | get files | |
| fallbackToMilestoneDueDate | No | set due date as milestone due date if due date is null and there's a related milestone | |
| extractTemplateRoleName | No | For tasks created in a project template it's possible to assign a role instead of people, companies or teams. This role is then stored with the task name as a prefix. When this flag is enabled it will extract the role name and return it inside a special field. | |
| excludeAssigneeNotOnProjectTeams | No | exclude assignee not on project teams | |
| completedOnly | No | only completed tasks | |
| checkForReminders | No | check if task has reminders | |
| allowAssigneesOutsideProject | No | when filtering by assigned or unassigned tasks, include assignees that are not in the project. | |
| tasksSelectedColumns | No | customize the report by selecting columns to be displayed for tasks report | |
| tasklistIds | No | filter by tasklist ids | |
| taskgroupIds | No | filter by taskgroup ids | |
| taskIncludedSet | No | filter by task included set | |
| tags | No | filter by tag values | |
| tagIds | No | filter by tag ids | |
| status | No | filter by list of task status | |
| skipCRMDealIds | No | skip crm deal ids | |
| selectedColumns | No | customize the report by selecting columns to be displayed for planned vs actual. | |
| responsiblePartyIds | No | filter by responsible party ids | |
| projectTagIds | No | filter by project tag ids | |
| projectStatuses | No | filter by project status | |
| projectOwnerIds | No | filter by project owner ids | |
| projectIds | No | filter by project ids | |
| projectHealths | No | filter by project healths 0: not set 1: bad 2: ok 3: good | |
| projectFeaturesEnabled | No | filter by projects that have features enabled | |
| projectCompanyIds | No | filter by company ids | |
| projectCategoryIds | No | filter by project category ids | |
| includeCustomFieldIds | No | include specific custom fields | |
| include | No | include | |
| ids | No | filter by task ids | |
| followedByUserIds | No | filter by followed by user ids | |
| filterBoardColumnIds | No | filter by board column ids | |
| fieldsUsers | No | Query parameter: fields[users] | |
| fieldsTimers | No | Query parameter: fields[timers] | |
| fieldsTeams | No | Query parameter: fields[teams] | |
| fieldsTasks | No | Query parameter: fields[tasks] | |
| fieldsTasklists | No | Query parameter: fields[tasklists] | |
| fieldsTaskgroups | No | Query parameter: fields[taskgroups] | |
| fieldsTaskSequences | No | Query parameter: fields[taskSequences] | |
| fieldsTags | No | Query parameter: fields[tags] | |
| fieldsProjects | No | Query parameter: fields[projects] | |
| fieldsMilestones | No | Query parameter: fields[milestones] | |
| fieldsLockdowns | No | Query parameter: fields[lockdowns] | |
| fieldsGroups | No | Query parameter: fields[groups] | |
| fieldsFiles | No | Query parameter: fields[files] | |
| fieldsCustomfields | No | Query parameter: fields[customfields] | |
| fieldsCustomfieldTasks | No | Query parameter: fields[customfieldTasks] | |
| fieldsCompanies | No | Query parameter: fields[companies] | |
| fieldsComments | No | Query parameter: fields[comments] | |
| fieldsColumns | No | Query parameter: fields[columns] | |
| fieldsCards | No | Query parameter: fields[cards] | |
| fieldsProjectPermissions | No | Query parameter: fields[ProjectPermissions] | |
| expandedIds | No | the ids of the expanded tasks | |
| excludeTagIds | No | filter by excluded tag ids | |
| crmDealIds | No | filter by crm deal ids | |
| createdByUserIds | No | filter by creator user ids | |
| assigneeTeamIds | No | filter by assignee team ids | |
| assigneeCompanyIds | No | filter by assignee company ids | |
| CustomFields | No | filter by custom fields |
Implementation Reference
- src/tools/tasks/getTasks.ts:979-1030 (handler)The main tool handler function 'handleGetTasks' that maps camelCase parameters to API format, calls the teamworkService.getTasks() service, and returns the response formatted as MCP content.
// Tool handler export async function handleGetTasks(input: any) { logger.info("Calling teamworkService.getTasks()"); // Map camelCase field names back to API format const apiInput: Record<string, any> = { ...input }; // Define the mapping for fields[...] parameters const fieldMappings: Record<string, string> = { fieldsUsers: "fields[users]", fieldsTimers: "fields[timers]", fieldsTeams: "fields[teams]", fieldsTasks: "fields[tasks]", fieldsTasklists: "fields[tasklists]", fieldsTaskgroups: "fields[taskgroups]", fieldsTaskSequences: "fields[taskSequences]", fieldsTags: "fields[tags]", fieldsProjects: "fields[projects]", fieldsMilestones: "fields[milestones]", fieldsLockdowns: "fields[lockdowns]", fieldsGroups: "fields[groups]", fieldsFiles: "fields[files]", fieldsCustomfields: "fields[customfields]", fieldsCustomfieldTasks: "fields[customfieldTasks]", fieldsCompanies: "fields[companies]", fieldsComments: "fields[comments]", fieldsColumns: "fields[columns]", fieldsCards: "fields[cards]", fieldsProjectPermissions: "fields[ProjectPermissions]", }; for (const [camelCaseKey, apiKey] of Object.entries(fieldMappings)) { if (apiInput[camelCaseKey] !== undefined) { apiInput[apiKey] = apiInput[camelCaseKey]; delete apiInput[camelCaseKey]; } } try { const tasks = await teamworkService.getTasks(apiInput); logger.info("Tasks response received"); return { content: [{ type: "text", text: JSON.stringify(tasks, null, 2) }] }; } catch (error: any) { return createErrorResponse(error, 'Retrieving tasks'); } } - src/tools/tasks/getTasks.ts:11-976 (schema)The tool definition 'getTasksDefinition' including inputSchema with all filter/pagination parameters (dates, priorities, statuses, task IDs, etc.) and annotations.
export const getTasksDefinition = { name: "getTasks", description: "Get tasks, Return multiple tasks according to the optional provided filter.", inputSchema: { type: "object", properties: { updatedBefore: { type: "string", description: "filter by updated before date" }, updatedAfter: { type: "string", description: "filter by updated after date" }, today: { type: "string", description: "filter by today" }, taskFilter: { type: "string", description: "filter by a taskFilter", enum: [ "all", "anytime", "completed", "created", "overdue", "today", "yesterday", "started", "tomorrow", "thisweek", "within7", "within14", "within30", "within365", "nodate", "noduedate", "nostartdate", "newTaskDefaults", "hasDate" ] }, startDate: { type: "string", description: "filter on start date" }, searchTerm: { type: "string", description: "filter by search term" }, reportType: { type: "string", description: "define the type of the report", enum: [ "plannedvsactual", "task", "tasktime" ] }, reportFormat: { type: "string", description: "define the format of the report", enum: [ "html", "pdf" ] }, priority: { type: "string", description: "filter by task priority" }, orderMode: { type: "string", description: "order mode", enum: [ "asc", "desc" ] }, orderBy: { type: "string", description: "order by", enum: [ "startdate", "createdat", "priority", "project", "flattenedtasklist", "company", "manual", "active", "completedat", "duestartdate", "alldates", "tasklistname", "tasklistdisplayorder", "tasklistid", "duedate", "updatedat", "taskname", "createdby", "completedby", "assignedto", "taskstatus", "taskduedate", "customfield", "estimatedtime", "boardcolumn", "taskgroupid", "taskgroupname", "taskgroup", "displayorder", "projectmanual", "stagedisplayorder", "stage" ] }, notCompletedBefore: { type: "string", description: "filter by projects that have not been completed before the given date" }, endDate: { type: "string", description: "filter on end date" }, dueBefore: { type: "string", description: "filter before a due date" }, dueAfter: { type: "string", description: "filter after a due date" }, deletedAfter: { type: "string", description: "filter on deleted after date" }, createdFilter: { type: "string", description: "filter by created filter", enum: [ "anytime", "today", "yesterday", "custom" ] }, createdDateCode: { type: "string", description: "filter by created date code" }, createdBefore: { type: "string", description: "filter by created before date" }, createdAfter: { type: "string", description: "filter by created after date" }, completedBefore: { type: "string", description: "filter by completed before date" }, completedAfter: { type: "string", description: "filter by completed after date" }, updatedByUserId: { type: "integer", description: "filter by updated user id" }, parentTaskId: { type: "integer", description: "filter by parent task ids" }, pageSize: { type: "integer", description: "number of items in a page" }, page: { type: "integer", description: "page number" }, orderByCustomFieldId: { type: "integer", description: "order by custom field id when orderBy is equal to custom field" }, includeTaskId: { type: "integer", description: "include task id" }, filterId: { type: "integer", description: "provide a user saved filter ID" }, completedByUserId: { type: "integer", description: "filter by completed user id" }, useTaskDateRange: { type: "boolean", description: "use date range logic from table when getting the tasks" }, useStartDatesForTodaysTasks: { type: "boolean", description: "use start dates for todays tasks" }, useFormulaFields: { type: "boolean", description: "use formula fields" }, useAllProjects: { type: "boolean", description: "filter on all projects" }, sortActiveFirst: { type: "boolean", description: "sort active tasks first" }, skipCounts: { type: "boolean", description: "Skip counts allows you to skip doing counts on a list API endpoint for performance reasons." }, showDeleted: { type: "boolean", description: "include deleted items" }, showCompletedLists: { type: "boolean", description: "include tasks from completed lists" }, searchCompaniesTeams: { type: "boolean", description: "include companies and teams in the search term" }, searchAssignees: { type: "boolean", description: "include assignees in the search" }, onlyUntaggedTasks: { type: "boolean", description: "only untagged tasks" }, onlyUnplanned: { type: "boolean", description: "only return tasks that are unplanned. Not assigned, no due date or missing estimated time." }, onlyTasksWithUnreadComments: { type: "boolean", description: "filter by only tasks with unread comments" }, onlyTasksWithTickets: { type: "boolean", description: "filter by only tasks with tickets" }, onlyTasksWithEstimatedTime: { type: "boolean", description: "only return tasks with estimated time" }, onlyStarredProjects: { type: "boolean", description: "filter by starred projects only" }, onlyAdminProjects: { type: "boolean", description: "only include tasks from projects where the user is strictly a project admin. site admins have visibility to all projects." }, nestSubTasks: { type: "boolean", description: "nest sub tasks" }, matchAllTags: { type: "boolean", description: "match all tags" }, matchAllProjectTags: { type: "boolean", description: "match all project tags" }, matchAllExcludedTags: { type: "boolean", description: "match all exclude tags" }, isReportDownload: { type: "boolean", description: "generate a report export." }, includeUpdate: { type: "boolean", description: "include tasks latest update action" }, includeUntaggedTasks: { type: "boolean", description: "include untagged tasks" }, includeTomorrow: { type: "boolean", description: "filter by include tomorrow" }, includeToday: { type: "boolean", description: "filter by include today" }, includeTeamUserIds: { type: "boolean", description: "include members of the given teams" }, includeTasksWithoutDueDates: { type: "boolean", description: "include tasks without due dates" }, includeTasksWithCards: { type: "boolean", description: "include tasks with cards" }, includeTasksFromDeletedLists: { type: "boolean", description: "include tasks from deleted lists" }, includeTasksCount: { type: "boolean", description: "include total count of tasks for given filter" }, includeRelatedTasks: { type: "boolean", description: "include ids of active subtasks, dependencies, predecessors" }, includePrivateItems: { type: "boolean", description: "include private items" }, includeOverdueTasks: { type: "boolean", description: "include overdue tasks" }, includeOriginalDueDate: { type: "boolean", description: "include original due date of a task" }, includeCustomFields: { type: "boolean", description: "include custom fields" }, includeCompletedTasks: { type: "boolean", description: "include completed tasks" }, includeCompletedPredecessors: { type: "boolean", description: "include ids of completed predecessors. It must be provided with includeRelatedTasks flag or with the predecessors sideload." }, includeCompanyUserIds: { type: "boolean", description: "include members of the given companies" }, includeCommentStats: { type: "boolean", description: "include number of unread and read comments for each task" }, includeBlocked: { type: "boolean", description: "filter by include blocked" }, includeAttachmentCommentStats: { type: "boolean", description: "include number of unread and read comments for each file attachment" }, includeAssigneeTeams: { type: "boolean", description: "include teams related to the responsible user ids" }, includeAssigneeCompanies: { type: "boolean", description: "include companies related to the responsible user ids" }, includeArchivedProjects: { type: "boolean", description: "include archived projects" }, includeAllComments: { type: "boolean", description: "include all comments" }, groupByTasklist: { type: "boolean", description: "group by tasklist" }, groupByTaskgroup: { type: "boolean", description: "group by taskgroup" }, getSubTasks: { type: "boolean", description: "get sub tasks" }, getFiles: { type: "boolean", description: "get files" }, fallbackToMilestoneDueDate: { type: "boolean", description: "set due date as milestone due date if due date is null and there's a related milestone" }, extractTemplateRoleName: { type: "boolean", description: "For tasks created in a project template it's possible to assign a role instead of people, companies or teams. This role is then stored with the task name as a prefix. When this flag is enabled it will extract the role name and return it inside a special field." }, excludeAssigneeNotOnProjectTeams: { type: "boolean", description: "exclude assignee not on project teams" }, completedOnly: { type: "boolean", description: "only completed tasks" }, checkForReminders: { type: "boolean", description: "check if task has reminders" }, allowAssigneesOutsideProject: { type: "boolean", description: "when filtering by assigned or unassigned tasks, include assignees that are not in the project." }, tasksSelectedColumns: { type: "array", description: "customize the report by selecting columns to be displayed for tasks report" }, tasklistIds: { type: "array", description: "filter by tasklist ids" }, taskgroupIds: { type: "array", description: "filter by taskgroup ids" }, taskIncludedSet: { type: "array", description: "filter by task included set" }, tags: { type: "array", description: "filter by tag values" }, tagIds: { type: "array", description: "filter by tag ids" }, status: { type: "array", description: "filter by list of task status" }, skipCRMDealIds: { type: "array", description: "skip crm deal ids" }, selectedColumns: { type: "array", description: "customize the report by selecting columns to be displayed for planned vs actual." }, responsiblePartyIds: { type: "array", description: "filter by responsible party ids" }, projectTagIds: { type: "array", description: "filter by project tag ids" }, projectStatuses: { type: "array", description: "filter by project status" }, projectOwnerIds: { type: "array", description: "filter by project owner ids" }, projectIds: { type: "array", description: "filter by project ids" }, projectHealths: { type: "array", description: "filter by project healths 0: not set 1: bad 2: ok 3: good" }, projectFeaturesEnabled: { type: "array", description: "filter by projects that have features enabled" }, projectCompanyIds: { type: "array", description: "filter by company ids" }, projectCategoryIds: { type: "array", description: "filter by project category ids" }, includeCustomFieldIds: { type: "array", description: "include specific custom fields" }, include: { type: "array", description: "include" }, ids: { type: "array", description: "filter by task ids" }, followedByUserIds: { type: "array", description: "filter by followed by user ids" }, filterBoardColumnIds: { type: "array", description: "filter by board column ids" }, fieldsUsers: { type: "array", description: "Query parameter: fields[users]", items: { type: "string", enum: [ "id", "firstName", "lastName", "title", "email", "companyId", "company", "isAdmin", "isClientUser", "isServiceAccount", "type", "deleted", "avatarUrl", "lengthOfDay", "workingHoursId", "workingHour", "userRate", "userCost", "canAddProjects" ] } }, fieldsTimers: { type: "array", description: "Query parameter: fields[timers]", items: { type: "string", enum: [ "id", "userId", "taskId", "projectId", "description", "running", "billable", "deleted", "dateCreated", "dateDeleted", "duration", "lastStartedAt", "serverTime", "intervals" ] } }, fieldsTeams: { type: "array", description: "Query parameter: fields[teams]", items: { type: "string", enum: [ "id", "name", "teamLogo", "teamLogoIcon", "teamLogoColor" ] } }, fieldsTasks: { type: "array", description: "Query parameter: fields[tasks]", items: { type: "string", enum: [ "id", "name", "dateUpdated", "parentTaskId", "isPrivate", "status", "tasklistId", "startDate", "dueDate" ] } }, fieldsTasklists: { type: "array", description: "Query parameter: fields[tasklists]", items: { type: "string", enum: [ "id", "name", "projectId", "milestoneId" ] } }, fieldsTaskgroups: { type: "array", description: "Query parameter: fields[taskgroups]", items: { type: "string", enum: [ "id", "name", "description", "displayOrder", "projectId", "status" ] } }, fieldsTaskSequences: { type: "array", description: "Query parameter: fields[taskSequences]", items: { type: "string", enum: [ "id", "installationId", "frequency", "selectedWeekDays", "endDate", "monthlyRepeatType", "duration", "rrule" ] } }, fieldsTags: { type: "array", description: "Query parameter: fields[tags]", items: { type: "string", enum: [ "id", "name", "color", "count" ] } }, fieldsProjects: { type: "array", description: "Query parameter: fields[projects]", items: { type: "string", enum: [ "id", "name" ] } }, fieldsMilestones: { type: "array", description: "Query parameter: fields[milestones]", items: { type: "string", enum: [ "id", "name", "description", "deadline", "completed", "projectId", "createdOn", "lastChangedOn", "creatorUserId", "reminder", "private", "lockdownId", "status", "completedOn", "completerId", "percentageComplete" ] } }, fieldsLockdowns: { type: "array", description: "Query parameter: fields[lockdowns]", items: { type: "string", enum: [ "id", "userID", "updatedAt", "itemType", "itemID", "grantAccessTo" ] } }, fieldsGroups: { type: "array", description: "Query parameter: fields[groups]", items: { type: "string", enum: [ "late", "today", "tomorrow", "later-this-week", "next-week", "later", "no-due-date" ] } }, fieldsFiles: { type: "array", description: "Query parameter: fields[files]", items: { type: "string", enum: [ "isPrivate", "latestFileVersionNo", "versionId", "status", "description", "lockdownId", "tagIds", "changeFollowers", "commentFollowers", "originalName", "displayName", "isLocked", "lockedByUserId", "lockedDate", "size", "uploadedDate", "uploadedByUserID", "updatedAt", "deletedAt", "deletedBy", "fileSource", "projectId", "numLikes", "reactions", "versions", "downloadURL", "previewURL", "thumbURL", "relatedItems", "commentsCount", "commentsCountRead", "categoryId" ] } }, fieldsCustomfields: { type: "array", description: "Query parameter: fields[customfields]", items: { type: "string", enum: [ "id", "projectId", "entity", "name", "description", "type", "options", "visibilities", "isPrivate", "required", "createdAt", "createdByUserId", "updatedAt", "updatedByUserId", "deleted", "deletedAt", "deletedByUserId" ] } }, fieldsCustomfieldTasks: { type: "array", description: "Query parameter: fields[customfieldTasks]", items: { type: "string", enum: [ "id", "customfieldId", "value", "createdAt", "createdBy" ] } }, fieldsCompanies: { type: "array", description: "Query parameter: fields[companies]", items: { type: "string", enum: [ "id", "name", "logoUploadedToServer", "logoImage" ] } }, fieldsComments: { type: "array", description: "Query parameter: fields[comments]", items: { type: "string", enum: [ "id", "objectType", "objectId", "title" ] } }, fieldsColumns: { type: "array", description: "Query parameter: fields[columns]", items: { type: "string", enum: [ "id", "name", "color", "displayOrder", "createdAt", "updatedAt", "settings", "sort", "sortOrder", "deletedAt", "project", "hasTriggers", "deleted", "stats", "defaultTasklist" ] } }, fieldsCards: { type: "array", description: "Query parameter: fields[cards]", items: { type: "string", enum: [ "id", "displayOrder", "archived", "archivedAt", "archivedBy", "createdAt", "createBy", "updatedAt", "visible", "status", "deleteBy", "deletedAt" ] } }, fieldsProjectPermissions: { type: "array", description: "Query parameter: fields[ProjectPermissions]", items: { type: "string", enum: [ "viewMessagesAndFiles", "viewTasksAndMilestones", "viewTime", "viewNotebooks", "viewRiskRegister", "viewEstimatedTime", "viewInvoices", "addTasks", "addRisks", "manageCustomFields", "addExpenses", "editAllTasks", "addMilestones", "addTaskLists", "addMessages", "addFiles", "addTime", "addNotebooks", "viewLinks", "addLinks", "canViewForms", "addForms", "viewAllTimeLogs", "setPrivacy", "projectAdministrator", "viewProjectUpdate", "addProjectUpdate", "canViewProjectMembers", "canViewProjectBudget", "canManageProjectBudget", "canViewRates", "canManageRates", "canViewSchedule", "canManageSchedule", "receiveEmailNotifications", "isObserving", "isArchived", "active", "canAccess", "inOwnerCompany", "canManagePeople", "canViewProjectTemplates", "canManageProjectTemplates" ] } }, expandedIds: { type: "array", description: "the ids of the expanded tasks" }, excludeTagIds: { type: "array", description: "filter by excluded tag ids" }, crmDealIds: { type: "array", description: "filter by crm deal ids" }, createdByUserIds: { type: "array", description: "filter by creator user ids" }, assigneeTeamIds: { type: "array", description: "filter by assignee team ids" }, assigneeCompanyIds: { type: "array", description: "filter by assignee company ids" }, CustomFields: { type: "array", description: "filter by custom fields" } } }, annotations: { title: "Get Tasks from Teamwork", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false } }; - src/tools/index.ts:12-69 (registration)Import and registration of getTasks definition and handler in the central tools index. Line 69 registers { definition: getTasks, handler: handleGetTasks } in the toolPairs array, and line 108-111 builds a name-to-handler map.
import { getTasksDefinition as getTasks, handleGetTasks } from './tasks/getTasks.js'; import { getTasksByProjectIdDefinition as getTasksByProjectId, handleGetTasksByProjectId } from './tasks/getTasksByProjectId.js'; import { getTasksByTaskListIdDefinition as getTasksByTaskListId, handleGetTasksByTaskListId } from './tasks/getTasksByTaskListId.js'; import { getTaskListsByProjectIdDefinition as getTaskListsByProjectId, handleGetTaskListsByProjectId } from './tasks/getTaskListsByProjectId.js'; import { getTaskByIdDefinition as getTaskById, handleGetTaskById } from './tasks/getTaskById.js'; import { createTaskDefinition as createTask, handleCreateTask } from './tasks/createTask.js'; import { createSubTaskDefinition as createSubTask, handleCreateSubTask } from './tasks/createSubTask.js'; import { updateTaskDefinition as updateTask, handleUpdateTask } from './tasks/updateTask.js'; import { deleteTaskDefinition as deleteTask, handleDeleteTask } from './tasks/deleteTask.js'; import { getTasksMetricsCompleteDefinition as getTasksMetricsComplete, handleGetTasksMetricsComplete } from './tasks/getTasksMetricsComplete.js'; import { getTasksMetricsLateDefinition as getTasksMetricsLate, handleGetTasksMetricsLate } from './tasks/getTasksMetricsLate.js'; import { getTaskSubtasksDefinition as getTaskSubtasks, handleGetTaskSubtasks } from './tasks/getTaskSubtasks.js'; import { getTaskCommentsDefinition as getTaskComments, handleGetTaskComments } from './tasks/getTaskComments.js'; // Comments import { createCommentDefinition as createComment, handleCreateComment } from './comments/createComment.js'; // People import { getPeopleDefinition as getPeople, handleGetPeople } from './people/getPeople.js'; import { getPersonByIdDefinition as getPersonById, handleGetPersonById } from './people/getPersonById.js'; import { getProjectPeopleDefinition as getProjectPeople, handleGetProjectPeople } from './people/getProjectPeople.js'; import { addPeopleToProjectDefinition as addPeopleToProject, handleAddPeopleToProject } from './people/addPeopleToProject.js'; import { deletePersonDefinition as deletePerson, handleDeletePerson } from './people/deletePerson.js'; import { updatePersonDefinition as updatePerson, handleUpdatePerson } from './people/updatePerson.js'; // Companies import { createCompanyDefinition as createCompany, handleCreateCompany } from './companies/createCompany.js'; import { updateCompanyDefinition as updateCompany, handleUpdateCompany } from './companies/updateCompany.js'; import { deleteCompanyDefinition as deleteCompany, handleDeleteCompany } from './companies/deleteCompany.js'; import { getCompaniesDefinition as getCompanies, handleGetCompanies } from './companies/getCompanies.js'; import { getCompanyByIdDefinition as getCompanyById, handleGetCompanyById } from './companies/getCompanyById.js'; // Reporting import { getProjectsPeopleMetricsPerformanceDefinition as getProjectsPeopleMetricsPerformance, handleGetProjectsPeopleMetricsPerformance } from './people/getPeopleMetricsPerformance.js'; import { getProjectsPeopleUtilizationDefinition as getProjectsPeopleUtilization, handleGetProjectsPeopleUtilization } from './people/getPeopleUtilization.js'; import { getProjectPersonDefinition as getProjectPerson, handleGetProjectPerson } from './people/getProjectPerson.js'; import { getProjectsReportingUserTaskCompletionDefinition as getProjectsReportingUserTaskCompletion, handleGetProjectsReportingUserTaskCompletion } from './reporting/getUserTaskCompletion.js'; import { getProjectsReportingUtilizationDefinition as getProjectsReportingUtilization, handleGetProjectsReportingUtilization } from './people/getUtilization.js'; // Time-related imports import { getTimeDefinition as getTime, handleGetTime } from './time/getTime.js'; import { getProjectsAllocationsTimeDefinition as getAllocationTime, handleGetProjectsAllocationsTime } from './time/getAllocationTime.js'; // Core import { getTimezonesDefinition as getTimezones, handleGetTimezones } from './core/getTimezones.js'; // Define a structure that pairs tool definitions with their handlers interface ToolPair { definition: any; handler: Function; } // Create an array of tool pairs const toolPairs: ToolPair[] = [ { definition: getProjects, handler: handleGetProjects }, { definition: getCurrentProject, handler: handleGetCurrentProject }, { definition: createProject, handler: handleCreateProject }, { definition: getTasks, handler: handleGetTasks }, - src/services/tasks/getTasks.ts:9-32 (helper)The service layer function 'getTasks' that makes the actual HTTP GET request to the Teamwork API endpoint '/tasks.json' with query parameters.
export const getTasks = async (params: Record<string, any> = {}) => { try { const api = ensureApiClient(); // The tool handler is now responsible for ensuring correct parameter names. // No filtering is needed here; pass the params directly. logger.debug(`Making GET request to /tasks.json with params: ${JSON.stringify(params)}`); const response = await api.get('/tasks.json', { params: params }); return response.data; } catch (error: any) { if (error.response) { logger.error(`Error fetching tasks: Status ${error.response.status} - ${JSON.stringify(error.response.data)}`); } else if (error.request) { logger.error(`Error fetching tasks: No response received - ${error.request}`); } else { logger.error(`Error fetching tasks: ${error.message}`); } throw new Error(`Failed to fetch tasks from Teamwork API: ${error.message}`); } }; export default getTasks;