Skip to main content
Glama
bswa006

AI Agent Template MCP Server

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[];
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states 'track and analyze,' which implies a read or monitoring operation, but doesn't clarify if this is a write operation (e.g., logging data), a read-only query, or something else. It lacks details on permissions, side effects, rate limits, or output format, which are critical for a tool with complex nested parameters.

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

Conciseness5/5

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

The description is a single, efficient sentence with no wasted words. It's front-loaded with the core purpose, making it easy to scan and understand quickly. This is an example of appropriate conciseness for a tool description.

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?

Given the complexity (4 parameters with nested objects), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what the tool returns, how to interpret the metrics, or any behavioral context needed for proper invocation. For a tool with such rich input structure, more guidance is necessary to ensure the agent can use it correctly.

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 50%, with detailed descriptions for some parameters (e.g., 'featureName' and 'timestamp') but not for others (e.g., 'metrics' and 'improvements' objects). The description adds no additional parameter semantics beyond what the schema provides, so it doesn't compensate for the coverage gap. This results in a baseline score of 3, as the schema does some heavy lifting but not fully.

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

Purpose4/5

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

The description 'Track and analyze AI agent performance metrics' clearly states the verb ('track and analyze') and resource ('AI agent performance metrics'), making the purpose understandable. However, it doesn't distinguish this tool from potential sibling tools that might also analyze performance in different contexts, so it lacks sibling differentiation.

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

Usage Guidelines2/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. It doesn't mention any prerequisites, exclusions, or specific contexts for usage, leaving the agent to infer usage based on the name alone. This is a significant gap in helping the agent select the right tool.

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

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