Skip to main content
Glama

listModels

Retrieve all locally stored statistical models to generate realistic MongoDB-compatible data from sample documents or descriptions.

Instructions

Get a list of all available statistical models stored locally

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Primary handler implementation for the 'listModels' tool. Lists all DataFlood models by fetching collections from storage and loading detailed model information for each.
    async listModels() {
        const models = [];
        const collections = await this.storage.listCollections(config.storage.defaultDatabase);
        
        for (const name of collections) {
            try {
                const model = await this.storage.getModel(config.storage.defaultDatabase, name);
                if (model) {
                    models.push({
                        name,
                        properties: Object.keys(model.properties || {}),
                        description: model.description || `DataFlood model for ${name}`
                    });
                } else {
                    // Add model even if we can't load it fully
                    models.push({
                        name,
                        properties: [],
                        description: `Model ${name} (loading error)`
                    });
                }
            } catch (err) {
                this.logger.warn(`Error loading model ${name}:`, err.message);
                // Still add the model to the list
                models.push({
                    name,
                    properties: [],
                    description: `Model ${name} available`
                });
            }
        }
        
        return {
            count: models.length,
            models
        };
    }
  • Tool registration in the server's tools array, defining name, description, and empty input schema.
    {
        name: 'listModels',
        description: 'List all available DataFlood models',
        inputSchema: {
            type: 'object',
            properties: {}
        }
    },
  • Alternative handler for 'listModels' in the MCP SDK-based server implementation, syncing models from storage and returning a formatted text list.
    case 'listModels':
      // Always check filesystem first for persistent models
      const persistentModels = await storage.listModels();
      
      // Sync in-memory models with filesystem
      for (const modelName of persistentModels) {
        if (!models.has(modelName)) {
          try {
            const modelData = await storage.getModel(config.storage.defaultDatabase, modelName);
            if (modelData) {
              models.set(modelName, modelData);
            }
          } catch (error) {
            logger.warn(`Failed to load model ${modelName}: ${error.message}`);
          }
        }
      }
      
      const modelList = Array.from(models.entries()).map(([name, data]) => ({
        name,
        samples: data.samples?.length || 0,
        trained: data.trained || false,
        fields: Object.keys(data.schema?.properties || {})
      }));
      
      return {
        content: [{
          type: 'text',
          text: `Available DataFlood models:\n${modelList.map(m => `- ${m.name}: ${m.samples} samples, ${m.fields.length} fields`).join('\n') || 'No models found'}`
        }]
      };
  • Tool registration in the TOOLS array for the SDK-based MCP server.
    name: 'listModels',
    description: 'Get a list of all available statistical models stored locally',
    inputSchema: {
      type: 'object',
      properties: {}
    }
  • Supporting storage method listModels() that scans model directories for JSON files listing available models, called by both MCP server handlers.
    async listModels() {
        const models = [];
        
        // Check default database directory
        const mcpDir = join(this.basePath, this.defaultDatabase);
        if (existsSync(mcpDir)) {
            const files = readdirSync(mcpDir);
            for (const file of files) {
                if (file.endsWith('.json')) {
                    models.push(file.replace('.json', ''));
                }
            }
        }
        
        // Check trained directory
        const trainedDir = join(this.basePath, 'trained');
        if (existsSync(trainedDir)) {
            const files = readdirSync(trainedDir);
            for (const file of files) {
                if (file.endsWith('.json')) {
                    const modelName = file.replace('.json', '');
                    if (!models.includes(modelName)) {
                        models.push(modelName);
                    }
                }
            }
        }
        
        return models;
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but only states it retrieves a list without disclosing behavioral traits. It doesn't mention whether this is a read-only operation, if it requires authentication, how results are formatted (e.g., pagination, sorting), or potential rate limits. This leaves significant gaps for a tool that interacts with stored data.

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 that front-loads the core action ('Get a list') and specifies scope ('all available statistical models stored locally'). There is zero waste, and every word contributes to understanding the tool's purpose.

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 simplicity (0 parameters, no output schema) and lack of annotations, the description is incomplete. It doesn't explain what the output looks like (e.g., list format, model identifiers), behavioral constraints, or how it fits with siblings like 'getModelInfo'. For a tool that likely returns structured data, more context is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters, and schema description coverage is 100%, so no parameter documentation is needed. The description appropriately doesn't discuss parameters, earning a baseline 4 for not introducing confusion or redundancy.

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 ('Get') and resource ('list of all available statistical models stored locally'), making the purpose unambiguous. It distinguishes from siblings like 'getModelInfo' (detailed info on one model) and 'trainModel' (creation). However, it doesn't explicitly differentiate from 'queryModel' (which might also involve listing), so it's not a perfect 5.

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 like 'getModelInfo' for detailed model metadata or 'queryModel' for filtered queries. It implies usage for retrieving all models but lacks explicit when/when-not instructions or prerequisite context.

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/smallmindsco/MongTap'

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