generate_custom_report
Create custom analytics reports with specified metrics and visualizations from project management data sources like tasks, documents, and team activities.
Instructions
Generate a custom analytics report with specified metrics and visualizations
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| report_name | Yes | Name for the custom report | |
| data_sources | Yes | Data sources to include in the report | |
| metrics_config | No | Configuration for metrics calculation | |
| output_format | No | Output format for the report | json |
| schedule | No | Optional scheduling configuration |
Implementation Reference
- src/tools/analytics-insights.ts:424-468 (handler)The primary handler function implementing the logic for the 'generate_custom_report' tool. It parses input arguments, logs the request, builds a report structure, collects data from specified sources using helper functions, calculates summaries, handles CSV and summary output formats, sets up scheduling if provided, and returns the report.export const generateCustomReport = requireAuth(async (args: any) => { const { report_name, data_sources, metrics_config, output_format, schedule } = GenerateCustomReportSchema.parse(args) logger.info('Generating custom report', { report_name, data_sources, output_format }) const report: any = { name: report_name, generated_at: new Date().toISOString(), data_sources, metrics_config: metrics_config || {}, data: {} } // Collect data from each source for (const source of data_sources) { try { report.data[source] = await collectReportData(source, metrics_config) } catch (error) { logger.error(`Failed to collect data from ${source}:`, error) report.data[source] = { error: 'Data collection failed' } } } // Calculate summary statistics report.summary = calculateReportSummary(report.data, metrics_config) // Format output based on requested format if (output_format === 'csv') { report.csv_data = convertToCSV(report.data) } else if (output_format === 'summary') { return { report_name, summary: report.summary, key_insights: generateReportInsights(report.data), generated_at: report.generated_at } } // Set up scheduling if requested if (schedule) { report.schedule_id = await scheduleReport(report_name, args, schedule) } return report })
- The Zod input schema used for validating the arguments passed to the generateCustomReport handler, defining required fields like report_name and data_sources, and optional configurations for metrics, output format, and scheduling.const GenerateCustomReportSchema = z.object({ report_name: z.string().min(1), data_sources: z.array(z.enum(['projects', 'tasks', 'documents', 'conversations', 'team_members', 'automations'])).min(1), metrics_config: z.object({ time_grouping: z.enum(['day', 'week', 'month']).default('week'), aggregation_method: z.enum(['sum', 'average', 'count']).default('count'), filters: z.record(z.any()).optional() }).optional(), output_format: z.enum(['json', 'csv', 'summary']).default('json'), schedule: z.object({ frequency: z.enum(['once', 'daily', 'weekly', 'monthly']), recipients: z.array(z.string()) }).optional() })
- src/tools/analytics-insights.ts:363-407 (registration)The MCPTool object that registers the 'generate_custom_report' tool, specifying its name, description, and input schema for the MCP system.export const generateCustomReportTool: MCPTool = { name: 'generate_custom_report', description: 'Generate a custom analytics report with specified metrics and visualizations', inputSchema: { type: 'object', properties: { report_name: { type: 'string', description: 'Name for the custom report' }, data_sources: { type: 'array', items: { type: 'string', enum: ['projects', 'tasks', 'documents', 'conversations', 'team_members', 'automations'] }, description: 'Data sources to include in the report' }, metrics_config: { type: 'object', properties: { time_grouping: { type: 'string', enum: ['day', 'week', 'month'], default: 'week' }, aggregation_method: { type: 'string', enum: ['sum', 'average', 'count'], default: 'count' }, filters: { type: 'object' } }, description: 'Configuration for metrics calculation' }, output_format: { type: 'string', enum: ['json', 'csv', 'summary'], default: 'json', description: 'Output format for the report' }, schedule: { type: 'object', properties: { frequency: { type: 'string', enum: ['once', 'daily', 'weekly', 'monthly'] }, recipients: { type: 'array', items: { type: 'string' } } }, description: 'Optional scheduling configuration' } }, required: ['report_name', 'data_sources'] } }
- src/tools/analytics-insights.ts:786-791 (registration)Export mapping tool names to their handler functions, including 'generate_custom_report' mapped to generateCustomReport, likely used for tool registration in the MCP system.export const analyticsInsightsHandlers = { get_project_analytics: getProjectAnalytics, get_team_productivity: getTeamProductivity, get_workspace_health: getWorkspaceHealth, generate_custom_report: generateCustomReport }
- src/tools/analytics-insights.ts:779-784 (registration)Export collecting all analytics tool definitions, including generateCustomReportTool, for bulk registration.export const analyticsInsightsTools = { getProjectAnalyticsTool, getTeamProductivityTool, getWorkspaceHealthTool, generateCustomReportTool }