get_pomodoro_stats
Retrieve productivity statistics for Pomodoro sessions to analyze work patterns and track progress over specified time periods.
Instructions
Get statistics about pomodoro sessions
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| period | No | Time period for stats |
Implementation Reference
- src/index.ts:464-498 (handler)The main handler logic for the 'get_pomodoro_stats' tool. It filters completed pomodoro sessions based on the specified period (today, week, month, or all), calculates statistics including total sessions, work sessions, break sessions, and total minutes worked, then returns the stats in JSON format.case "get_pomodoro_stats": { const period = (args.period as string) || "all"; let filteredSessions = data.sessions.filter((s) => s.completed); const now = new Date(); if (period === "today") { const today = new Date(now.setHours(0, 0, 0, 0)); filteredSessions = filteredSessions.filter( (s) => new Date(s.startTime) >= today ); } else if (period === "week") { const weekAgo = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000); filteredSessions = filteredSessions.filter( (s) => new Date(s.startTime) >= weekAgo ); } else if (period === "month") { const monthAgo = new Date(now.getTime() - 30 * 24 * 60 * 60 * 1000); filteredSessions = filteredSessions.filter( (s) => new Date(s.startTime) >= monthAgo ); } const stats = { totalSessions: filteredSessions.length, workSessions: filteredSessions.filter((s) => s.type === "work").length, breakSessions: filteredSessions.filter((s) => s.type !== "work").length, totalMinutes: filteredSessions.reduce((sum, s) => sum + s.duration, 0), period, }; return { content: [ { type: "text", text: JSON.stringify({ success: true, stats }, null, 2) }, ], }; }
- src/index.ts:198-211 (registration)Registration of the 'get_pomodoro_stats' tool in the TOOLS array, which is returned by the ListTools handler. Includes name, description, and input schema definition.{ name: "get_pomodoro_stats", description: "Get statistics about pomodoro sessions", inputSchema: { type: "object", properties: { period: { type: "string", enum: ["today", "week", "month", "all"], description: "Time period for stats", }, }, }, },
- src/index.ts:201-210 (schema)Input schema for the 'get_pomodoro_stats' tool, defining the optional 'period' parameter with allowed values: today, week, month, all.inputSchema: { type: "object", properties: { period: { type: "string", enum: ["today", "week", "month", "all"], description: "Time period for stats", }, }, },