business-intelligence-insights
Generate business insights from SAP data to identify trends, anomalies, and optimization opportunities using comprehensive analysis.
Instructions
Generate business insights from SAP data
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | ||
| entityTypes | No | SAP entity types to analyze | |
| serviceIds | No | SAP service IDs to include | |
| analysisType | No | Type of analysis to perform | comprehensive |
| timeWindow | No | Time window for analysis | |
| insightId | No | Specific insight ID (for get action) | |
| minConfidence | No | Minimum confidence threshold for insights | |
| includeRecommendations | No | Include actionable recommendations | |
| exportFormat | No | Export format (for export action) | json |
Implementation Reference
- src/tools/realtime-tools.ts:758-870 (handler)Main handler function that processes input arguments and dispatches to specific actions (generate, list, get, configure, export) for business intelligence insights, using RealtimeAnalyticsService and generating mock insights.
public async execute(args: z.infer<typeof this.inputSchema>): Promise<any> { logger.info('Generating business intelligence insights', { action: args.action, analysisType: args.analysisType, }); const service = getRealtimeService(); try { switch (args.action) { case 'generate': const insights = this.generateBusinessInsights(args); return { success: true, insights, analysis: { type: args.analysisType, timeWindow: args.timeWindow, entityTypes: args.entityTypes || ['SalesOrder', 'Product', 'Customer'], confidence: 0.85, dataPoints: Math.floor(Math.random() * 10000) + 5000, }, summary: { totalInsights: insights.length, highPriority: insights.filter(i => i.severity === 'critical' || i.severity === 'high') .length, categories: this.categorizeInsights(insights), generatedAt: new Date().toISOString(), }, recommendations: this.generateGlobalRecommendations(insights), }; case 'list': const existingInsights = service.getInsights(); return { success: true, insights: existingInsights.map(insight => ({ insightId: insight.insightId, title: insight.title, type: insight.type, severity: insight.severity, confidence: insight.confidence, generated: insight.generated, expires: insight.expires, })), total: existingInsights.length, active: existingInsights.filter(i => !i.expires || i.expires > new Date()).length, }; case 'get': if (!args.insightId) { throw new Error('Insight ID is required for get action'); } const insight = service.getInsights().find(i => i.insightId === args.insightId); if (!insight) { return { success: false, error: 'Insight not found', insightId: args.insightId, }; } return { success: true, insight: { ...insight, relatedInsights: this.findRelatedInsights(insight, service.getInsights()), actionsPlan: this.generateActionPlan(insight), }, }; case 'configure': const configuration = this.generateInsightConfiguration(args); return { success: true, message: 'Business intelligence engine configured', configuration, status: 'active', }; case 'export': const exportData = this.generateExportData(service.getInsights(), args.exportFormat!); return { success: true, export: exportData, format: args.exportFormat, recordCount: service.getInsights().length, generatedAt: new Date().toISOString(), }; default: throw new Error(`Unknown action: ${args.action}`); } } catch (error: any) { logger.error('Business intelligence error', { error: error.message }); return { success: false, error: error.message, action: args.action, troubleshooting: [ 'Ensure sufficient historical data exists for analysis', 'Verify entity types and service IDs are accessible', 'Check minimum confidence threshold settings', ], }; } } - src/tools/realtime-tools.ts:717-754 (schema)Zod input schema defining parameters for the tool, including action, entityTypes, serviceIds, analysisType, timeWindow, etc.
public readonly inputSchema = z .object({ action: z.enum(['generate', 'list', 'get', 'configure', 'export']), entityTypes: z.array(z.string()).optional().describe('SAP entity types to analyze'), serviceIds: z.array(z.string()).optional().describe('SAP service IDs to include'), analysisType: z .enum(['trend', 'anomaly', 'correlation', 'optimization', 'comprehensive']) .optional() .default('comprehensive') .describe('Type of analysis to perform'), timeWindow: z .object({ period: z.enum(['hours', 'days', 'weeks', 'months']), size: z.number().positive(), }) .optional() .default({ period: 'days', size: 7 }) .describe('Time window for analysis'), insightId: z.string().optional().describe('Specific insight ID (for get action)'), minConfidence: z .number() .min(0) .max(1) .optional() .default(0.7) .describe('Minimum confidence threshold for insights'), includeRecommendations: z .boolean() .optional() .default(true) .describe('Include actionable recommendations'), exportFormat: z .enum(['json', 'csv', 'pdf']) .optional() .default('json') .describe('Export format (for export action)'), }) .describe('Business intelligence insights configuration'); - src/tools/realtime-tools.ts:1122-1127 (registration)Registration of the BusinessIntelligenceInsightsTool instance in the realtimeAnalyticsTools array, which is likely imported and registered with the MCP server elsewhere.
export const realtimeAnalyticsTools = [ new RealTimeDataStreamTool(), new KPIDashboardBuilderTool(), new PredictiveAnalyticsEngineTool(), new BusinessIntelligenceInsightsTool(), ]; - src/tools/realtime-tools.ts:872-898 (helper)Key helper method that generates the actual business insights (trend, anomaly, correlation, optimization) based on input parameters.
private generateBusinessInsights(args: any): any[] { const insights = []; const analysisTypes = args.analysisType === 'comprehensive' ? ['trend', 'anomaly', 'correlation', 'optimization'] : [args.analysisType]; for (const type of analysisTypes) { switch (type) { case 'trend': insights.push(...this.generateTrendInsights()); break; case 'anomaly': insights.push(...this.generateAnomalyInsights()); break; case 'correlation': insights.push(...this.generateCorrelationInsights()); break; case 'optimization': insights.push(...this.generateOptimizationInsights()); break; } } // Filter by confidence threshold return insights.filter(insight => insight.confidence >= args.minConfidence); } - src/tools/realtime-tools.ts:714-754 (helper)Tool metadata: name and description definition.
public readonly name = 'business-intelligence-insights'; public readonly description = 'Generate business insights from SAP data'; public readonly inputSchema = z .object({ action: z.enum(['generate', 'list', 'get', 'configure', 'export']), entityTypes: z.array(z.string()).optional().describe('SAP entity types to analyze'), serviceIds: z.array(z.string()).optional().describe('SAP service IDs to include'), analysisType: z .enum(['trend', 'anomaly', 'correlation', 'optimization', 'comprehensive']) .optional() .default('comprehensive') .describe('Type of analysis to perform'), timeWindow: z .object({ period: z.enum(['hours', 'days', 'weeks', 'months']), size: z.number().positive(), }) .optional() .default({ period: 'days', size: 7 }) .describe('Time window for analysis'), insightId: z.string().optional().describe('Specific insight ID (for get action)'), minConfidence: z .number() .min(0) .max(1) .optional() .default(0.7) .describe('Minimum confidence threshold for insights'), includeRecommendations: z .boolean() .optional() .default(true) .describe('Include actionable recommendations'), exportFormat: z .enum(['json', 'csv', 'pdf']) .optional() .default('json') .describe('Export format (for export action)'), }) .describe('Business intelligence insights configuration');