getTime
Retrieve logged time entries from Teamwork projects with filters for date ranges, project status, billing status, and sorting options to track work hours and generate reports.
Instructions
Get all time entries. Return all logged time entries for all projects. Only the time entries that the logged-in user can access will be returned.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| updatedAfter | No | filter by updated after date | |
| startDate | No | filter by a starting date | |
| reportFormat | No | define the format of the report | |
| projectStatus | No | filter by project status | |
| orderMode | No | order mode | |
| orderBy | No | sort order | |
| invoicedType | No | filter by invoiced type | |
| endDate | No | filter by an ending date | |
| billableType | No | filter by billable type | |
| updatedBy | No | filter by the user who updated the timelog | |
| ticketId | No | filter by ticket id | |
| tasklistId | No | filter by tasklist id | |
| taskId | No | filter by task id (deprecated, use taskIds) | |
| projectId | No | filter by project id (deprecated, use projectIds) | |
| pageSize | No | number of items in a page | |
| page | No | page number | |
| invoiceId | No | filter by invoice id | |
| budgetId | No | filter by budget id | |
| allocationId | No | filter by allocation id |
Implementation Reference
- src/tools/time/getTime.ts:139-154 (handler)MCP tool handler for 'getTime'. Calls the service with input params and returns JSON stringified response or error.export async function handleGetTime(input: any) { try { logger.info('Handling getTime tool request'); const response = await getTimeService(input); logger.info('Successfully handled getTime request'); return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] }; } catch (error: any) { return createErrorResponse(error, 'Getting time entries'); } }
- src/tools/time/getTime.ts:8-134 (schema)Tool schema/definition for 'getTime' including inputSchema for parameters like dates, filters, pagination, etc.export const getTimeDefinition = { name: "getTime", description: "Get all time entries. Return all logged time entries for all projects. Only the time entries that the logged-in user can access will be returned.", inputSchema: { type: 'object', properties: { updatedAfter: { type: 'string', description: 'filter by updated after date' }, startDate: { type: 'string', description: 'filter by a starting date' }, reportFormat: { type: 'string', description: 'define the format of the report' }, projectStatus: { type: 'string', description: 'filter by project status', enum: [ 'active', 'current', 'late', 'upcoming', 'completed', 'deleted' ] }, orderMode: { type: 'string', description: 'order mode', enum: [ 'asc', 'desc' ] }, orderBy: { type: 'string', description: 'sort order', enum: [ 'company', 'date', 'dateupdated', 'project', 'task', 'tasklist', 'user', 'description', 'billed', 'billable', 'timespent' ] }, invoicedType: { type: 'string', description: 'filter by invoiced type', enum: [ 'all', 'invoiced', 'noninvoiced' ] }, endDate: { type: 'string', description: 'filter by an ending date' }, billableType: { type: 'string', description: 'filter by billable type', enum: [ 'all', 'billable', 'non-billable' ] }, updatedBy: { type: 'integer', description: 'filter by the user who updated the timelog' }, ticketId: { type: 'integer', description: 'filter by ticket id' }, tasklistId: { type: 'integer', description: 'filter by tasklist id' }, taskId: { type: 'integer', description: 'filter by task id (deprecated, use taskIds)' }, projectId: { type: 'integer', description: 'filter by project id (deprecated, use projectIds)' }, pageSize: { type: 'integer', description: 'number of items in a page' }, page: { type: 'integer', description: 'page number' }, invoiceId: { type: 'integer', description: 'filter by invoice id' }, budgetId: { type: 'integer', description: 'filter by budget id' }, allocationId: { type: 'integer', description: 'filter by allocation id' } }, required: [] }, annotations: { title: "Get Time Entries", readOnlyHint: false, destructiveHint: false, openWorldHint: false } };
- src/tools/index.ts:97-97 (registration)Registration of 'getTime' tool in the toolPairs array, mapping definition to handler for toolHandlersMap.{ definition: getTime, handler: handleGetTime },
- src/services/time/getTime.ts:73-88 (helper)Core service function getTime that makes API call to '/time.json' with params and returns data. Called by the tool handler.export const getTime = async (params: GetTimeParams = {}) => { try { logger.info('Fetching time entries from Teamwork'); const api = getApiClientForVersion('v3'); logger.info('Making API request to get time entries'); const response = await api.get('/time.json', { params }); logger.info('Successfully retrieved time entries'); return response.data; } catch (error: any) { logger.error(`Failed to get time entries: ${error.message}`); throw new Error(`Failed to get time entries: ${error.message}`); } };