Skip to main content
Glama
saralegui-solutions

MCP Self-Learning Server

get_performance_metrics

Retrieve detailed performance metrics from the self-learning server to analyze tool usage patterns and track system improvements over time.

Instructions

Get detailed performance metrics

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
timeRangeNoall

Implementation Reference

  • The core handler function that implements the get_performance_metrics tool. It extracts metrics from the learning engine, applies time range filtering (placeholder), computes detailed tool usage and error breakdowns, and includes recommendations.
    async handleGetPerformanceMetrics(args) {
      const { timeRange = 'all' } = args;
      const metrics = { ...this.learningEngine.metrics };
      
      // Filter by time range if needed
      if (timeRange !== 'all') {
        // In production, would filter based on actual timestamps
        metrics.timeRange = timeRange;
      }
      
      // Add detailed breakdowns
      metrics.toolBreakdown = Array.from(metrics.toolUsageFrequency.entries())
        .map(([tool, count]) => ({ tool, count, percentage: (count / metrics.totalInteractions * 100).toFixed(2) }));
      
      metrics.errorBreakdown = Array.from(metrics.errorPatterns.entries())
        .map(([error, count]) => ({ error, count }));
      
      return {
        success: true,
        metrics,
        recommendations: this.learningEngine.generateGlobalRecommendations()
      };
    }
  • Input schema defining the parameters for the tool, specifically an optional 'timeRange' with allowed values.
    inputSchema: {
      type: 'object',
      properties: {
        timeRange: {
          type: 'string',
          enum: ['hour', 'day', 'week', 'all'],
          default: 'all'
        }
      }
    }
  • Tool registration in the MCP server's tools array, specifying name, description, and input schema for MCP discovery.
    {
      name: 'get_performance_metrics',
      description: 'Get detailed performance metrics',
      inputSchema: {
        type: 'object',
        properties: {
          timeRange: {
            type: 'string',
            enum: ['hour', 'day', 'week', 'all'],
            default: 'all'
          }
        }
      }
    }
  • Dispatch case in the MCP tool request handler that routes calls to get_performance_metrics to its handler function.
    case 'get_performance_metrics':
      result = await this.handleGetPerformanceMetrics(args);
      break;

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/saralegui-solutions/mcp-self-learning-server'

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