generate_weekly_summary
Generate structured weekly productivity summaries by analyzing Slack, Calendar, and Gmail data to track progress and identify patterns.
Instructions
Generate a comprehensive weekly productivity summary from Slack, Calendar, and Gmail data. Returns structured summary with optional HTML/Markdown output.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| days_back | No | Number of days to analyze (default: 7) | |
| start_date | No | Optional start date in YYYY-MM-DD format (overrides days_back) | |
| end_date | No | Optional end date in YYYY-MM-DD format (default: today) | |
| output_format | No | Output format(s) to generate (default: both) | both |
| save_to_file | No | Whether to save output to summaries directory (default: true) | |
| include_sections | No | Sections to include (default: all) |
Implementation Reference
- src/tools/generate-summary.js:18-86 (handler)Main handler function that orchestrates weekly summary generation: calculates date range, generates data collection instructions and template, processes collected data if provided, handles file output in HTML/Markdown, and returns structured result.export async function generateWeeklySummary(args) { const startTime = Date.now(); try { // Calculate date range const { startDate, endDate, days } = calculateDateRange(args); const outputFormat = args.output_format || config.defaults.outputFormat; const saveToFile = args.save_to_file !== false; const includeSections = args.include_sections || ['executive', 'time', 'achievements', 'communication', 'todos', 'insights', 'metrics']; // Generate data collection instructions for the AI const instructions = generateDataCollectionInstructions(startDate, endDate); // Generate summary template const summaryTemplate = generateSummaryTemplate(startDate, endDate, days, includeSections); // Prepare response structure const result = { success: true, message: 'Weekly summary generation initiated. Please follow the data collection instructions below.', period: { start: startDate, end: endDate, days, }, instructions, template: summaryTemplate, output_format: outputFormat, save_to_file: saveToFile, note: 'This tool provides instructions for the AI agent to collect data and generate the summary. The AI will make multiple MCP calls to gather Slack, Calendar, and Gmail data, then synthesize it into a comprehensive summary.', }; // If the AI has already collected data (passed in args), process it if (args.collected_data) { result.summary = await processSummaryData(args.collected_data, startDate, endDate, days, includeSections); // Save to file if requested if (saveToFile) { const files = []; if (outputFormat === 'both' || outputFormat === 'html') { const htmlFilename = generateFilename(startDate, endDate, 'html'); const htmlPath = await saveSummary(result.summary.html, htmlFilename); files.push(htmlPath); } if (outputFormat === 'both' || outputFormat === 'markdown') { const mdFilename = generateFilename(startDate, endDate, 'markdown'); const mdPath = await saveSummary(result.summary.markdown, mdFilename); files.push(mdPath); } result.files_saved = files; } } result.generation_time_ms = Date.now() - startTime; return result; } catch (error) { throw { code: error.code || 'GENERATION_FAILED', message: error.message || 'Failed to generate summary', details: error.details || error.stack, }; } }
- src/tools/index.js:45-89 (schema)JSON schema defining the input parameters and validation for the generate_weekly_summary tool.{ name: 'generate_weekly_summary', description: 'Generate a comprehensive weekly productivity summary from Slack, Calendar, and Gmail data. Returns structured summary with optional HTML/Markdown output.', inputSchema: { type: 'object', properties: { days_back: { type: 'integer', description: 'Number of days to analyze (default: 7)', default: 7, minimum: 1, maximum: 90, }, start_date: { type: 'string', description: 'Optional start date in YYYY-MM-DD format (overrides days_back)', pattern: '^\\d{4}-\\d{2}-\\d{2}$', }, end_date: { type: 'string', description: 'Optional end date in YYYY-MM-DD format (default: today)', pattern: '^\\d{4}-\\d{2}-\\d{2}$', }, output_format: { type: 'string', enum: ['both', 'html', 'markdown', 'json'], description: 'Output format(s) to generate (default: both)', default: 'both', }, save_to_file: { type: 'boolean', description: 'Whether to save output to summaries directory (default: true)', default: true, }, include_sections: { type: 'array', items: { type: 'string', enum: ['executive', 'time', 'achievements', 'communication', 'todos', 'insights', 'metrics'], }, description: 'Sections to include (default: all)', }, }, }, },
- src/tools/handler.js:27-29 (registration)Registration in the central tool dispatcher: routes calls to 'generate_weekly_summary' to the specific handler function.case 'generate_weekly_summary': result = await generateWeeklySummary(args); break;
- src/index.js:58-60 (registration)MCP server request handler for tool calls, which invokes the dispatcher handleToolCall based on tool name.// Handle the tool call (returns JSON string) const result = await handleToolCall(name, args || {});
- src/tools/generate-summary.js:91-123 (helper)Helper function that generates detailed data collection instructions for Slack, Calendar, and Gmail analyzers.function generateDataCollectionInstructions(startDate, endDate) { return ` # Weekly Summary Data Collection To generate a comprehensive weekly summary for **${formatDisplayDate(startDate)} to ${formatDisplayDate(endDate)}**, please collect data from the following sources: ${getSlackDataInstructions(startDate, endDate)} ${getCalendarDataInstructions(startDate, endDate)} ${getGmailDataInstructions(startDate, endDate)} ## Next Steps 1. Make the necessary MCP tool calls to collect data from each source 2. Analyze the data to identify: - Key achievements and wins - Time allocation patterns - Communication trends - Outstanding action items - Insights and learnings 3. Synthesize the findings into the summary template provided 4. Generate both HTML and Markdown output formats ## Important Notes - Focus on **actionable insights** and **meaningful patterns** - Highlight **achievements** and **accomplishments** - Identify **blockers** and **challenges** that need attention - Extract **concrete action items** from messages and emails - Provide **context** for metrics and statistics `; }