Skip to main content
Glama
bswa006
by bswa006

track_agent_performance

Monitor and analyze AI agent performance metrics including token usage, execution time, validation scores, security assessments, and test coverage to identify areas for improvement.

Instructions

Track and analyze AI agent performance metrics

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
featureNameYesName of the feature being tracked
timestampYesISO timestamp of the feature completion
metricsYes
improvementsNo

Implementation Reference

  • The core handler function that processes input metrics, calculates scores, generates reports with recommendations, trends, and achievements, and updates agent memory/context files.
    export async function trackAgentPerformance( metrics: PerformanceMetrics ): Promise<PerformanceReport> { const report: PerformanceReport = { success: false, summary: { overallScore: 0, efficiency: '', quality: '', security: '', }, recommendations: [], trends: { tokenUsage: 'stable', quality: 'stable', speed: 'stable', }, achievements: [], }; try { // Calculate overall score const scores = { validation: metrics.metrics.validationScore, security: metrics.metrics.securityScore, coverage: metrics.metrics.testCoverage, efficiency: calculateEfficiencyScore(metrics), errorFree: calculateErrorScore(metrics), }; const overallScore = Math.round( (scores.validation * 0.25 + scores.security * 0.25 + scores.coverage * 0.2 + scores.efficiency * 0.15 + scores.errorFree * 0.15) ); // Update report summary report.summary.overallScore = overallScore; report.summary.efficiency = getEfficiencyRating(metrics); report.summary.quality = getQualityRating(scores.validation, scores.coverage); report.summary.security = getSecurityRating(scores.security); // Update agent memory with performance data updateAgentMemory(metrics, overallScore); // Analyze trends report.trends = analyzeTrends(metrics); // Generate recommendations report.recommendations = generateRecommendations(metrics, scores); // Check for achievements report.achievements = checkAchievements(metrics, overallScore); // Update context with current metrics updateAgentContext(metrics); report.success = true; } catch (error) { report.success = false; report.recommendations = [`Error tracking performance: ${error}`]; } return report; }
  • MCP tool definition with input schema specifying the structure for performance metrics and optional improvements.
    { name: 'track_agent_performance', description: 'Track and analyze AI agent performance metrics', inputSchema: { type: 'object', properties: { featureName: { type: 'string', description: 'Name of the feature being tracked', }, timestamp: { type: 'string', description: 'ISO timestamp of the feature completion', }, metrics: { type: 'object', properties: { tokensUsed: { type: 'number' }, timeElapsed: { type: 'number' }, validationScore: { type: 'number' }, securityScore: { type: 'number' }, testCoverage: { type: 'number' }, hallucinations: { type: 'object', properties: { detected: { type: 'number' }, prevented: { type: 'number' }, examples: { type: 'array', items: { type: 'string' }, }, }, }, errors: { type: 'object', properties: { syntax: { type: 'number' }, runtime: { type: 'number' }, type: { type: 'number' }, }, }, }, required: ['tokensUsed', 'timeElapsed', 'validationScore', 'securityScore', 'testCoverage'], }, improvements: { type: 'object', properties: { tokenReduction: { type: 'number' }, timeReduction: { type: 'number' }, qualityIncrease: { type: 'number' }, }, }, }, required: ['featureName', 'timestamp', 'metrics'], }, },
  • Tool registration in the MCP server handler: parses arguments with Zod schema matching the tool definition and calls the trackAgentPerformance handler.
    case 'track_agent_performance': { const params = z.object({ featureName: z.string(), timestamp: z.string(), metrics: z.object({ tokensUsed: z.number(), timeElapsed: z.number(), validationScore: z.number(), securityScore: z.number(), testCoverage: z.number(), hallucinations: z.object({ detected: z.number(), prevented: z.number(), examples: z.array(z.string()), }).optional().default({ detected: 0, prevented: 0, examples: [], }), errors: z.object({ syntax: z.number(), runtime: z.number(), type: z.number(), }).optional().default({ syntax: 0, runtime: 0, type: 0, }), }), improvements: z.object({ tokenReduction: z.number().optional(), timeReduction: z.number().optional(), qualityIncrease: z.number().optional(), }).optional(), }).parse(args); const result = await trackAgentPerformance(params); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
  • TypeScript interface defining the input structure for PerformanceMetrics used by the handler.
    interface PerformanceMetrics { featureName: string; timestamp: string; metrics: { tokensUsed: number; timeElapsed: number; // in seconds validationScore: number; // 0-100 securityScore: number; // 0-100 testCoverage: number; // percentage hallucinations: { detected: number; prevented: number; examples: string[]; }; errors: { syntax: number; runtime: number; type: number; }; }; improvements?: { tokenReduction?: number; timeReduction?: number; qualityIncrease?: number; }; }
  • TypeScript interface defining the output structure for PerformanceReport returned by the handler.
    interface PerformanceReport { success: boolean; summary: { overallScore: number; efficiency: string; quality: string; security: string; }; recommendations: string[]; trends: { tokenUsage: 'improving' | 'stable' | 'degrading'; quality: 'improving' | 'stable' | 'degrading'; speed: 'improving' | 'stable' | 'degrading'; }; achievements: string[]; }

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/bswa006/mcp-context-manager'

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