toggl_daily_report
Generate daily time tracking reports by project and workspace with hours breakdown in JSON or text format for productivity analysis.
Instructions
Generate a daily report with hours by project and workspace
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | No | Date for report (YYYY-MM-DD format, defaults to today) | |
| format | No | Output format (default: json) |
Implementation Reference
- src/index.ts:553-580 (handler)Main execution logic for the 'toggl_daily_report' tool. Fetches time entries for the given date (or today), hydrates with project/workspace names from cache, generates structured report using helper, and returns as JSON or formatted text.case 'toggl_daily_report': { await ensureCache(); const date = args?.date ? new Date(args.date as string) : new Date(); const nextDay = new Date(date); nextDay.setDate(nextDay.getDate() + 1); const entries = await api.getTimeEntriesForDateRange(date, nextDay); const hydrated = await cache.hydrateTimeEntries(entries); const report = generateDailyReport(date.toISOString().split('T')[0], hydrated); if (args?.format === 'text') { return { content: [{ type: 'text', text: formatReportForDisplay(report) }] }; } return { content: [{ type: 'text', text: JSON.stringify(report, null, 2) }] }; }
- src/index.ts:230-247 (schema)Tool metadata and input schema definition, including parameters for date and output format.name: 'toggl_daily_report', description: 'Generate a daily report with hours by project and workspace', inputSchema: { type: 'object', properties: { date: { type: 'string', description: 'Date for report (YYYY-MM-DD format, defaults to today)' }, format: { type: 'string', enum: ['json', 'text'], description: 'Output format (default: json)' } } }, }, {
- src/utils.ts:223-250 (helper)Generates the structured DailyReport from hydrated time entries, computing totals, transforming entries, and creating summaries grouped by project and workspace.export function generateDailyReport(date: string, entries: HydratedTimeEntry[]): DailyReport { const totalSeconds = calculateTotalDuration(entries); const reportEntries = entries.map(createReportEntry); // Group by project const byProject = groupEntriesByProject(entries); const projectSummaries: ProjectSummary[] = []; byProject.forEach((projectEntries, projectName) => { projectSummaries.push(generateProjectSummary(projectName, projectEntries)); }); // Group by workspace const byWorkspace = groupEntriesByWorkspace(entries); const workspaceSummaries: WorkspaceSummary[] = []; byWorkspace.forEach((wsEntries, wsName) => { const wsId = wsEntries[0]?.workspace_id || 0; workspaceSummaries.push(generateWorkspaceSummary(wsName, wsId, wsEntries)); }); return { date, total_hours: secondsToHours(totalSeconds), total_seconds: totalSeconds, entries: reportEntries, by_project: projectSummaries, by_workspace: workspaceSummaries }; }
- src/index.ts:386-388 (registration)Registers the tool list (including toggl_daily_report) for the ListToolsRequestSchema, making it discoverable by MCP clients.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });