Skip to main content
Glama

listModels

Retrieve all available statistical models stored locally for generating 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

  • Main handler function for the 'listModels' MCP tool. Lists all available DataFlood models by enumerating collections and loading their schemas.
    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 schema definition including name, description, and empty input schema for 'listModels'.
    { name: 'listModels', description: 'List all available DataFlood models', inputSchema: { type: 'object', properties: {} } },
  • Dispatch/registration of the 'listModels' tool handler within the tool call switch statement.
    case 'listModels': result = await this.listModels(); break;
  • Alternative handler for 'listModels' tool in the SDK-based MCP server implementation. Uses storage.listModels() to list persistent models.
    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 schema definition for 'listModels' in the SDK-based MCP server.
    { name: 'listModels', description: 'Get a list of all available statistical models stored locally', inputSchema: { type: 'object', properties: {} }

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