Skip to main content
Glama
Raistlin82

SAP OData to MCP Server

by Raistlin82

kpi-dashboard-builder

Build and manage KPI dashboards using SAP OData services to monitor business metrics through charts, tables, and forecasts with automated data refresh.

Instructions

Create and manage KPI dashboards

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYes
dashboardNoDashboard configuration (required for create)
dashboardIdNoDashboard ID (required for update/delete/get/refresh)
includeDataNoInclude current KPI data in response
updatesNoFields to update (for update action)

Implementation Reference

  • Main handler function for the 'kpi-dashboard-builder' tool. Handles actions: create, list, get, refresh. Uses RealtimeAnalyticsService and generates mock data for dashboard management.
    public async execute(args: z.infer<typeof this.inputSchema>): Promise<any> { logger.info('Managing KPI dashboard', { action: args.action, dashboardId: args.dashboardId }); const service = getRealtimeService(); try { switch (args.action) { case 'create': if (!args.dashboard) { throw new Error('Dashboard configuration is required for create action'); } const dashboardId = `dashboard_${Date.now()}_${Math.random().toString(36).substr(2, 6)}`; // Simulate dashboard creation const createdDashboard = { dashboardId, name: args.dashboard.name, description: args.dashboard.description || '', kpis: args.dashboard.kpis.map((kpi, index) => ({ widgetId: `widget_${dashboardId}_${index}`, name: kpi.name, type: kpi.type, entityType: kpi.entityType, serviceId: kpi.serviceId, aggregation: kpi.aggregation, timeWindow: kpi.timeWindow, currentValue: this.generateMockKPIValue(kpi.type), trend: this.generateMockTrend(), status: 'active', })), layout: { columns: 12, rows: Math.ceil(args.dashboard.kpis.length / 3), responsive: true, theme: 'sap_horizon', }, refreshInterval: args.dashboard.refreshInterval, created: new Date().toISOString(), status: 'active', }; return { success: true, message: `KPI Dashboard '${args.dashboard.name}' created successfully`, dashboard: createdDashboard, capabilities: [ 'Real-time data visualization', 'Automated threshold alerts', 'Trend analysis and forecasting', 'Interactive drill-down capabilities', ], nextSteps: [ 'Connect to real-time data stream for live updates', 'Configure alert thresholds and notifications', 'Customize visualization themes and layouts', ], }; case 'list': const dashboards = service.getDashboards(); return { success: true, dashboards: dashboards.map(d => ({ dashboardId: d.dashboardId, name: d.name, description: d.description, widgetCount: d.kpis.length, owner: d.owner, created: d.created, status: d.isActive ? 'active' : 'inactive', })), total: dashboards.length, summary: `Found ${dashboards.length} KPI dashboards`, }; case 'get': if (!args.dashboardId) { throw new Error('Dashboard ID is required for get action'); } // Simulate dashboard retrieval const mockDashboard = this.generateMockDashboard(args.dashboardId); return { success: true, dashboard: mockDashboard, realTimeStatus: 'connected', lastUpdated: new Date().toISOString(), }; case 'refresh': if (!args.dashboardId) { throw new Error('Dashboard ID is required for refresh action'); } // Simulate data refresh const refreshedData = this.generateMockRefreshData(); return { success: true, dashboardId: args.dashboardId, refreshed: new Date().toISOString(), updates: refreshedData, message: 'Dashboard data refreshed successfully', }; default: throw new Error(`Unknown action: ${args.action}`); } } catch (error: any) { logger.error('KPI Dashboard error', { error: error.message }); return { success: false, error: error.message, action: args.action, troubleshooting: [ 'Verify dashboard configuration is valid', 'Ensure entity types and service IDs exist', 'Check real-time data stream connectivity', ], }; } }
  • Zod input schema defining parameters for KPI dashboard operations including action types and dashboard configuration using KPIDashboardSchema.
    public readonly inputSchema = z .object({ action: z.enum(['create', 'update', 'delete', 'list', 'get', 'refresh']), dashboardId: z .string() .optional() .describe('Dashboard ID (required for update/delete/get/refresh)'), dashboard: KPIDashboardSchema.optional().describe( 'Dashboard configuration (required for create)' ), updates: z.record(z.any()).optional().describe('Fields to update (for update action)'), includeData: z .boolean() .optional() .default(false) .describe('Include current KPI data in response'), }) .strict() .describe('KPI dashboard management');
  • Array collecting instances of realtime tools including KPIDashboardBuilderTool for registration in MCP server.
    export const realtimeAnalyticsTools = [ new RealTimeDataStreamTool(), new KPIDashboardBuilderTool(), new PredictiveAnalyticsEngineTool(), new BusinessIntelligenceInsightsTool(), ];
  • Helper method generating mock dashboard data for 'get' action.
    private generateMockDashboard(dashboardId: string): any { return { dashboardId, name: 'SAP Business Overview', description: 'Real-time business metrics and KPIs', widgets: [ { widgetId: 'widget_1', name: 'Total Revenue', type: 'metric', currentValue: 1250000, trend: { direction: 'up', percentage: 12.5 }, status: 'healthy', }, { widgetId: 'widget_2', name: 'Sales Trend', type: 'chart', currentValue: [850, 920, 1100, 980, 1250, 1180, 1300], trend: { direction: 'up', percentage: 8.2 }, status: 'healthy', }, ], layout: { columns: 12, rows: 4, theme: 'sap_horizon' }, refreshInterval: ANALYTICS_INTERVALS.DASHBOARD_REFRESH, lastUpdated: new Date().toISOString(), }; }
  • Helper method generating mock KPI values based on widget type used in dashboard creation.
    private generateMockKPIValue(type: string): any { const mockValues = { metric: Math.floor(Math.random() * 10000) + 1000, chart: Array(7) .fill(0) .map(() => Math.floor(Math.random() * 1000)), gauge: Math.floor(Math.random() * 100), table: Array(5) .fill(0) .map((_, i) => ({ id: i + 1, value: Math.random() * 1000 })), heatmap: Array(5) .fill(0) .map(() => Array(5) .fill(0) .map(() => Math.random()) ), forecast: Array(10) .fill(0) .map((_, i) => ({ period: i + 1, predicted: Math.random() * 1000, confidence: 0.8 + Math.random() * 0.2, })), comparison: { current: Math.random() * 1000, previous: Math.random() * 1000, target: Math.random() * 1200, }, }; return mockValues[type as keyof typeof mockValues] || mockValues.metric; }

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/Raistlin82/btp-sap-odata-to-mcp-server-optimized'

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