generate_analyst_report
Generate comprehensive analyst reports for Spanish stock exchange companies, sectors, or market themes with data visualizations and multiple analysis types.
Instructions
Generate a comprehensive analyst report for a company, sector, or market theme
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| subject | Yes | Company symbol, sector name, or theme to analyze | |
| report_type | Yes | Type of report to generate | |
| include_charts | No | Whether to include data visualizations (text-based) |
Implementation Reference
- src/analytics.ts:493-556 (handler)The main handler function that executes the generate_analyst_report tool logic. It generates comprehensive reports based on the subject (company/sector) and report_type, fetching data from DB and other analytics methods.async generateAnalystReport(subject: string, reportType: string, includeCharts: boolean = true): Promise<any> { try { const report = { subject: subject, report_type: reportType, generated_date: new Date().toISOString(), executive_summary: '', sections: {}, charts: includeCharts ? [] : null, conclusions: [], recommendations: [] }; switch (reportType) { case 'company_deep_dive': const company = await this.db.getCompanyBySymbol(subject); if (!company) throw new Error(`Company ${subject} not found`); report.sections = { company_overview: company, financial_metrics: { market_cap: company.market_cap, pe_ratio: company.price_to_earnings || company.pe_ratio, sector: company.sector }, governance_analysis: await this.getCompanyGovernanceAnalysis(company), market_position: await this.getCompanyMarketPosition(company), risk_assessment: await this.assessInvestmentRisk(subject), recent_developments: await this.db.getRecentNews(company.id, 10) }; report.executive_summary = this.generateCompanyExecutiveSummary(report.sections); break; case 'sector_overview': const sectorCompanies = await this.db.getCompaniesBySector(subject); const sectorAnalysis = await this.getSectorCorrelationAnalysis(30); report.sections = { sector_overview: { sector_name: subject, company_count: sectorCompanies.length, total_market_cap: sectorCompanies.reduce((sum, c) => sum + (c.market_cap || 0), 0) }, performance_analysis: sectorAnalysis, key_players: sectorCompanies.slice(0, 10), market_trends: await this.analyzeTrends('sector_trend', subject, 30), competitive_landscape: await this.analyzeSectorCompetition(sectorCompanies) }; break; // Add other report types as needed default: throw new Error(`Unknown report type: ${reportType}`); } report.conclusions = this.generateReportConclusions(report); report.recommendations = this.generateReportRecommendations(report); return report; } catch (error) { throw new Error(`Report generation failed: ${error}`); } }
- src/index.ts:458-480 (registration)Registers the 'generate_analyst_report' tool in the MCP server's listTools handler, including name, description, and input schema.name: 'generate_analyst_report', description: 'Generate a comprehensive analyst report for a company, sector, or market theme', inputSchema: { type: 'object', properties: { subject: { type: 'string', description: 'Company symbol, sector name, or theme to analyze', }, report_type: { type: 'string', enum: ['company_deep_dive', 'sector_overview', 'governance_analysis', 'market_opportunity', 'risk_assessment'], description: 'Type of report to generate', }, include_charts: { type: 'boolean', description: 'Whether to include data visualizations (text-based)', default: true, }, }, required: ['subject', 'report_type'], }, },
- src/index.ts:678-684 (schema)The dispatch handler in the main CallToolRequestSchema that validates input via args and delegates to the analytics handler.case 'generate_analyst_report': result = await this.analytics.generateAnalystReport( (args as any)?.subject, (args as any)?.report_type, (args as any)?.include_charts !== false ); break;