Skip to main content
Glama
Raistlin82

SAP OData to MCP Server

by Raistlin82

Create and manage KPI dashboards

kpi-dashboard-builder

Build and manage KPI dashboards by connecting to SAP OData services to visualize business metrics, charts, and data tables for monitoring performance.

Instructions

Create and manage KPI dashboards

Input Schema

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

Implementation Reference

  • Main handler function implementing the core logic for creating, listing, getting, and refreshing KPI dashboards using mock data and service integration.
    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',
          ],
        };
      }
    }
  • Input schema using Zod for validating tool parameters including action type, dashboard ID, configuration, and data inclusion options.
    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');
  • Zod schema defining the structure of a KPI dashboard configuration used in the tool's input validation.
    export const KPIDashboardSchema = z.object({
      name: z.string().min(1),
      description: z.string().optional(),
      kpis: z.array(
        z.object({
          name: z.string().min(1),
          type: z.enum(['metric', 'chart', 'gauge', 'table', 'heatmap', 'forecast', 'comparison']),
          entityType: z.string().min(1),
          serviceId: z.string().min(1),
          aggregation: z.enum(['sum', 'count', 'avg', 'min', 'max', 'distinct']),
          timeWindow: z.object({
            period: z.enum(['minutes', 'hours', 'days', 'weeks', 'months']),
            size: z.number().positive(),
          }),
        })
      ),
      refreshInterval: z.number().positive().default(30000),
    });
  • Array exporting the instantiated KPIDashboardBuilderTool for registration in the MCP tool registry.
    export const realtimeAnalyticsTools = [
      new RealTimeDataStreamTool(),
      new KPIDashboardBuilderTool(),
      new PredictiveAnalyticsEngineTool(),
      new BusinessIntelligenceInsightsTool(),
    ];
  • Helper method generating mock dashboard data for retrieval and demonstration purposes.
    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(),
      };
    }
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure but offers none. It doesn't mention authentication requirements, rate limits, whether operations are destructive, what happens when dashboards are deleted, or any side effects. The description simply repeats the tool's purpose without behavioral context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

While technically concise with just three words, this is under-specification rather than effective brevity. The description fails to front-load critical information and doesn't earn its place by adding value beyond what's already in the tool name and title. Every word should provide new information, but this description doesn't.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex tool with 5 parameters, nested objects, no output schema, and no annotations, the description is completely inadequate. It doesn't address the tool's multi-action nature, explain relationships between parameters, or provide any context about what 'managing' KPI dashboards entails in this specific system.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 80%, providing a solid baseline. The description adds no parameter information beyond what's in the schema, but with high schema coverage, this doesn't create a significant gap. The description doesn't compensate for the 20% coverage gap, but the schema does most of the work documenting the 5 parameters and their relationships.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tautological: description restates name/title.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With 18 sibling tools including ui-dashboard-composer and business-intelligence-insights, there's no indication of how this KPI-focused tool differs or when it should be preferred over other dashboard or analytics tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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