Skip to main content
Glama
janetsep

TreePod Financial MCP Agent

by janetsep

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
NameRequiredDescriptionDefault
report_typeNomonthly
formatNosummary

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.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.'
          );
        }
      }
    );
  • 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'),
      }),
  • Core handler logic for generateReport in BusinessCalculator class: dispatches to type-specific report generators based on report_type, with error handling
    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.'
        );
      }
    }
  • Helper method generateMonthlyReport: loads data, computes analysis, formats monthly report content
    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)
        }]
      };
    }
  • Helper method generateOccupancyReport: generates occupancy-focused report using domos status data
    async 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)
        }]
      };
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/janetsep/treepod-financial-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server