generate_report
Generate executive business reports using real-time data to analyze financial performance, occupancy metrics, and operational insights for TreePod Glamping.
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
- src/business/calculator.js:628-651 (handler)Core handler function that dispatches to specific report generators based on report_type parameter, loads real data, and handles errors.async 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.' ); } }
- server.js:185-228 (registration)Registers the 'generate_report' tool with MCP server, including input schema, title, description, and wrapper handler that validates inputs and delegates to businessCalculator.generateReport.server.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:190-193 (schema)Zod input schema defining report_type (monthly|occupancy|financial|competition) and format (summary|detailed) parameters.inputSchema: z.object({ report_type: z.string().default('monthly'), format: z.string().default('summary'), }),
- src/business/calculator.js:656-677 (helper)Helper function for generating monthly reports: loads financial, business status, and domos data, performs analysis, and formats output.async 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) }] }; }