toggl_get_time_entries
Retrieve time entries from Toggl Track with date range filters. Returns detailed entries including project and workspace information for tracking and reporting.
Instructions
Get time entries with optional date range filters. Returns hydrated entries with project/workspace names.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| period | No | Predefined period to fetch entries for | |
| start_date | No | Start date (YYYY-MM-DD format) | |
| end_date | No | End date (YYYY-MM-DD format) | |
| workspace_id | No | Filter by workspace ID | |
| project_id | No | Filter by project ID |
Implementation Reference
- src/index.ts:424-460 (handler)The main handler for the 'toggl_get_time_entries' tool. Ensures cache is warmed, determines date range from parameters (period, start_date, end_date), fetches time entries via TogglAPI, filters by workspace_id or project_id if provided, hydrates entries with project/workspace names from cache, and returns JSON with entry count and hydrated entries list.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)Defines the tool metadata including name, description, and input schema for 'toggl_get_time_entries'. The schema specifies optional parameters for filtering time entries by predefined periods or custom date ranges, and by workspace or project IDs.{ 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' } } }, },