toggl_get_time_entries
Retrieve time entries from Toggl Track with date range, workspace, or project filters to track and analyze logged work hours.
Instructions
Get time entries with optional date range filters. Returns hydrated entries with project/workspace names.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| end_date | No | End date (YYYY-MM-DD format) | |
| period | No | Predefined period to fetch entries for | |
| project_id | No | Filter by project ID | |
| start_date | No | Start date (YYYY-MM-DD format) | |
| workspace_id | No | Filter by workspace ID |
Implementation Reference
- src/index.ts:424-460 (handler)Main handler logic for the 'toggl_get_time_entries' tool. Computes date range from parameters, fetches entries via TogglAPI, applies optional filters for workspace and project, hydrates with project/workspace names using cache, and returns formatted JSON response.case 'toggl_get_time_entries': { await ensureCache(); let entries: TimeEntry[]; if (args?.period) { const range = getDateRange(args.period as any); entries = await api.getTimeEntriesForDateRange(range.start, range.end); } else if (args?.start_date || args?.end_date) { const start = args?.start_date ? new Date(args.start_date as string) : new Date(); const end = args?.end_date ? new Date(args.end_date as string) : new Date(); entries = await api.getTimeEntriesForDateRange(start, end); } else { entries = await api.getTimeEntriesForToday(); } // Filter by workspace/project if specified if (args?.workspace_id) { entries = entries.filter(e => e.workspace_id === args.workspace_id); } if (args?.project_id) { entries = entries.filter(e => e.project_id === args.project_id); } // Hydrate with names const hydrated = await cache.hydrateTimeEntries(entries); return { content: [{ type: 'text', text: JSON.stringify({ count: hydrated.length, entries: hydrated }, null, 2) }] }; }
- src/index.ts:149-178 (schema)Schema definition for the 'toggl_get_time_entries' tool, including name, description, and input schema with optional parameters for period, dates, workspace, and project filters.{ name: 'toggl_get_time_entries', description: 'Get time entries with optional date range filters. Returns hydrated entries with project/workspace names.', inputSchema: { type: 'object', properties: { period: { type: 'string', enum: ['today', 'yesterday', 'week', 'lastWeek', 'month', 'lastMonth'], description: 'Predefined period to fetch entries for' }, start_date: { type: 'string', description: 'Start date (YYYY-MM-DD format)' }, end_date: { type: 'string', description: 'End date (YYYY-MM-DD format)' }, workspace_id: { type: 'number', description: 'Filter by workspace ID' }, project_id: { type: 'number', description: 'Filter by project ID' } } }, },
- src/index.ts:386-388 (registration)Registers the list of tools including 'toggl_get_time_entries' for the ListToolsRequestSchema handler.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });