Skip to main content
Glama
Cappybara12

OpenXAI MCP Server

by Cappybara12

evaluate_explanation

Assess AI explanation quality using OpenXAI metrics like PGI, PGU, and RIS to measure faithfulness, robustness, and completeness for model transparency.

Instructions

Evaluate explanation quality using OpenXAI metrics

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
metricYesEvaluation metric to use (PGI, PGU, RIS, RRS, ROS, etc.)
explanationYesJSON string of the explanation to evaluate
model_infoYesInformation about the model

Implementation Reference

  • The core handler function for the 'evaluate_explanation' tool. It validates the metric, constructs a Python code example for evaluating explanations using OpenXAI's Evaluator class, and returns formatted response with evaluation details.
      async evaluateExplanation(metric, explanation, modelInfo) {
        const validMetrics = ['PGI', 'PGU', 'RIS', 'RRS', 'ROS', 'FA', 'RA', 'SA', 'SRA', 'RC', 'PRA'];
        
        if (!validMetrics.includes(metric)) {
          throw new Error(`Metric '${metric}' not supported. Available metrics: ${validMetrics.join(', ')}`);
        }
    
        const codeExample = `
    # Example usage with OpenXAI:
    from openxai import Evaluator
    from openxai import LoadModel
    from openxai import Explainer
    from openxai.dataloader import ReturnLoaders
    
    # Load model and data
    model = LoadModel(data_name='${modelInfo.data_name}', ml_model='${modelInfo.ml_model}', pretrained=True)
    trainloader, testloader = ReturnLoaders(data_name='${modelInfo.data_name}', download=True)
    
    # Generate explanations
    explainer = Explainer(method='lime', model=model)
    inputs, labels = next(iter(testloader))
    explanations = explainer.get_explanations(inputs)
    
    # Evaluate explanations
    evaluator = Evaluator(model, metric='${metric}')
    score = evaluator.evaluate(
        inputs=inputs,
        labels=labels,
        explanations=explanations
    )
    
    print(f"${metric} score: {score}")
    `;
    
        return {
          content: [
            {
              type: 'text',
              text: `Evaluated explanation using ${metric} metric\n\n` +
                    `Metric: ${metric}\n` +
                    `Dataset: ${modelInfo.data_name}\n` +
                    `Model: ${modelInfo.ml_model}\n` +
                    `Explanation: ${explanation}\n\n` +
                    `Python code example:\n\`\`\`python${codeExample}\`\`\``
            }
          ]
        };
      }
  • index.js:172-198 (registration)
    The tool registration entry in the list_tools response, including name, description, and input schema definition.
    {
      name: 'evaluate_explanation',
      description: 'Evaluate explanation quality using OpenXAI metrics',
      inputSchema: {
        type: 'object',
        properties: {
          metric: {
            type: 'string',
            description: 'Evaluation metric to use (PGI, PGU, RIS, RRS, ROS, etc.)',
            enum: ['PGI', 'PGU', 'RIS', 'RRS', 'ROS', 'FA', 'RA', 'SA', 'SRA', 'RC', 'PRA']
          },
          explanation: {
            type: 'string',
            description: 'JSON string of the explanation to evaluate'
          },
          model_info: {
            type: 'object',
            description: 'Information about the model',
            properties: {
              data_name: { type: 'string' },
              ml_model: { type: 'string' }
            }
          }
        },
        required: ['metric', 'explanation', 'model_info']
      }
    },
  • The input schema defining parameters for the evaluate_explanation tool: metric (enum), explanation (string), model_info (object).
    inputSchema: {
      type: 'object',
      properties: {
        metric: {
          type: 'string',
          description: 'Evaluation metric to use (PGI, PGU, RIS, RRS, ROS, etc.)',
          enum: ['PGI', 'PGU', 'RIS', 'RRS', 'ROS', 'FA', 'RA', 'SA', 'SRA', 'RC', 'PRA']
        },
        explanation: {
          type: 'string',
          description: 'JSON string of the explanation to evaluate'
        },
        model_info: {
          type: 'object',
          description: 'Information about the model',
          properties: {
            data_name: { type: 'string' },
            ml_model: { type: 'string' }
          }
        }
      },
      required: ['metric', 'explanation', 'model_info']
    }
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 the action ('evaluate') but lacks details on what the evaluation entails (e.g., scoring, validation, output format), whether it's read-only or mutative, performance characteristics, or error handling. This is inadequate for a tool with 3 parameters and no output schema.

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 zero waste. It's front-loaded with the core purpose ('evaluate explanation quality') and specifies the context ('using OpenXAI metrics') without unnecessary elaboration. Every word earns its place, making it highly concise and well-structured.

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 tool's complexity (3 parameters, nested objects, no output schema) and lack of annotations, the description is incomplete. It doesn't explain the evaluation process, output format, or behavioral traits. While schema coverage is high, the description fails to compensate for missing context, especially for a tool that likely returns evaluation results.

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?

Schema description coverage is 100%, so the schema already documents all parameters (metric, explanation, model_info) with descriptions and an enum for 'metric'. The description adds no additional meaning beyond the schema, such as explaining the relationship between parameters or typical values. Baseline 3 is appropriate when the schema does the heavy lifting.

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 clearly states the verb 'evaluate' and the resource 'explanation quality', specifying the domain as 'OpenXAI metrics'. It distinguishes from siblings like 'generate_explanation' (creation vs. evaluation) and 'list_metrics' (listing vs. applying). However, it doesn't explicitly contrast with all siblings, such as 'load_dataset' or 'get_leaderboard', which keeps it from a perfect score.

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 prerequisites (e.g., needing an explanation first), exclusions, or direct comparisons to siblings like 'list_metrics' (which might list available metrics) or 'generate_explanation' (which might produce explanations to evaluate). Usage is implied but not explicitly stated.

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/Cappybara12/mcpopenxAI'

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