generate_report
Generate business executive reports from real data to analyze financial performance and support decision-making.
Instructions
Genera reportes ejecutivos del negocio basado en datos reales
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| report_type | No | monthly | |
| format | No | summary |
Implementation Reference
- server.js:185-228 (registration)Registration of the 'generate_report' MCP tool, including input schema validation and wrapper handler that delegates core logic to businessCalculator.generateReportserver.registerTool( 'generate_report', { title: 'Generar reporte', description: 'Genera reportes ejecutivos del negocio basado en datos reales', inputSchema: z.object({ report_type: z.string().default('monthly'), format: z.string().default('summary'), }), }, async ({ report_type = 'monthly', format = 'summary' }) => { validator.log('info', `Iniciando generación de reporte tipo: ${report_type}, formato: ${format}`); try { // Validar parámetros de entrada const inputValidation = validator.validateUserInput({ report_type, format }, { report_type: { required: true, type: 'string', enum: ['monthly', 'occupancy', 'financial', 'competition'] }, format: { required: true, type: 'string', enum: ['summary', 'detailed'] } }); if (!inputValidation.valid) { return validator.generateInsufficientDataResponse( 'parámetros de reporte', `Errores: ${inputValidation.errors.join(', ')}` ); } const result = await businessCalculator.generateReport(report_type, format); validator.log('info', 'Reporte generado exitosamente'); return result; } catch (error) { validator.log('error', `Error crítico en generación de reporte: ${error.message}`); return validator.generateInsufficientDataResponse( 'generación de reporte', 'Error interno del sistema. Contacta al administrador.' ); } } );
- server.js:187-193 (schema)Input schema definition for generate_report tool using Zod: report_type (monthly|occupancy|financial|competition), format (summary|detailed){ title: 'Generar reporte', description: 'Genera reportes ejecutivos del negocio basado en datos reales', inputSchema: z.object({ report_type: z.string().default('monthly'), format: z.string().default('summary'), }),
- src/business/calculator.js:628-651 (handler)Core handler logic for generateReport in BusinessCalculator class: dispatches to type-specific report generators based on report_type, with error handlingasync generateReport(reportType, format = 'summary') { validator.log('info', `Generando reporte ${reportType} en formato ${format}`); try { switch (reportType) { case 'monthly': return await this.generateMonthlyReport(format); case 'occupancy': return await this.generateOccupancyReport(format); case 'financial': return await this.generateFinancialReport(format); case 'competition': return await this.generateCompetitionReport(format); default: return await this.generateMonthlyReport(format); } } catch (error) { validator.log('error', `Error generando reporte ${reportType}: ${error.message}`); return validator.generateInsufficientDataResponse( `reporte ${reportType}`, 'Error interno en la generación del reporte. Contacta al administrador.' ); } }
- src/business/calculator.js:656-677 (helper)Helper method generateMonthlyReport: loads data, computes analysis, formats monthly report contentasync generateMonthlyReport(format) { const financialData = await dataLoader.loadFinancialData(); const businessData = await dataLoader.loadBusinessStatus(); const domosStatus = await dataLoader.loadDomosStatus(); if (!financialData && !businessData) { return validator.generateInsufficientDataResponse( 'datos para reporte mensual', 'No se pudo acceder a los datos financieros ni de estado del negocio' ); } const analysis = this.calculateFinancialAnalysis(financialData || {}, 'Enero 2025'); const occupancyMetrics = domosStatus ? this.calculateOccupancyMetrics(domosStatus) : null; return { content: [{ type: 'text', text: this.formatMonthlyReport(analysis, occupancyMetrics, format) }] }; }
- src/business/calculator.js:682-702 (helper)Helper method generateOccupancyReport: generates occupancy-focused report using domos status dataasync generateOccupancyReport(format) { const businessData = await dataLoader.loadBusinessStatus(); const domosStatus = await dataLoader.loadDomosStatus(); if (!domosStatus) { return validator.generateInsufficientDataResponse( 'datos de ocupación', 'No se pudo acceder al estado actual de los domos' ); } const metrics = this.calculateOccupancyMetrics(domosStatus); const occupancyRate = businessData?.occupancy || 0; return { content: [{ type: 'text', text: this.formatOccupancyReport(metrics, occupancyRate, format) }] }; }