Skip to main content
Glama
Cappybara12

OpenXAI MCP Server

by Cappybara12

load_dataset

Load datasets like german, compas, or adult for evaluating AI explanation methods through the OpenXAI MCP Server interface.

Instructions

Load a specific dataset from OpenXAI

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataset_nameYesName of the dataset to load (e.g., german, compas, adult)
downloadNoWhether to download the dataset if not available locally

Implementation Reference

  • The primary handler function that executes the load_dataset tool. It retrieves dataset metadata for supported datasets (german, compas, adult), validates the dataset_name, and returns formatted information including dataset stats and a Python code example for loading the dataset using OpenXAI.
      async loadDataset(datasetName, download = true) {
        const datasetInfo = {
          german: {
            description: 'German Credit dataset loaded successfully',
            features: 20,
            samples: 1000,
            classes: 2,
            task: 'classification'
          },
          compas: {
            description: 'COMPAS Recidivism dataset loaded successfully',
            features: 11,
            samples: 6172,
            classes: 2,
            task: 'classification'
          },
          adult: {
            description: 'Adult Income dataset loaded successfully',
            features: 14,
            samples: 48842,
            classes: 2,
            task: 'classification'
          }
        };
    
        const info = datasetInfo[datasetName];
        if (!info) {
          throw new Error(`Dataset '${datasetName}' not found. Available datasets: ${Object.keys(datasetInfo).join(', ')}`);
        }
    
        const codeExample = `
    # Example usage with OpenXAI:
    from openxai.dataloader import ReturnLoaders
    
    # Load the dataset
    trainloader, testloader = ReturnLoaders(data_name='${datasetName}', download=${download})
    
    # Get a sample from the test dataset
    inputs, labels = next(iter(testloader))
    print(f"Input shape: {inputs.shape}")
    print(f"Labels shape: {labels.shape}")
    `;
    
        return {
          content: [
            {
              type: 'text',
              text: `${info.description}\n\n` +
                    `Dataset: ${datasetName}\n` +
                    `Features: ${info.features}\n` +
                    `Samples: ${info.samples}\n` +
                    `Classes: ${info.classes}\n` +
                    `Task: ${info.task}\n\n` +
                    `Python code example:\n\`\`\`python${codeExample}\`\`\``
            }
          ]
        };
      }
  • Input schema definition for the load_dataset tool, specifying dataset_name as required string and optional download boolean.
    inputSchema: {
      type: 'object',
      properties: {
        dataset_name: {
          type: 'string',
          description: 'Name of the dataset to load (e.g., german, compas, adult)',
        },
        download: {
          type: 'boolean',
          description: 'Whether to download the dataset if not available locally',
          default: true
        }
      },
      required: ['dataset_name']
    }
  • index.js:53-71 (registration)
    Registration of the load_dataset tool in the MCP server's tool list, including name, description, and input schema.
    {
      name: 'load_dataset',
      description: 'Load a specific dataset from OpenXAI',
      inputSchema: {
        type: 'object',
        properties: {
          dataset_name: {
            type: 'string',
            description: 'Name of the dataset to load (e.g., german, compas, adult)',
          },
          download: {
            type: 'boolean',
            description: 'Whether to download the dataset if not available locally',
            default: true
          }
        },
        required: ['dataset_name']
      }
    },
  • Dispatch case in the CallToolRequestHandler that routes load_dataset calls to the loadDataset method.
    case 'load_dataset':
      return await this.loadDataset(args.dataset_name, args.download);

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