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
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/mcp/mcp-server.js:1050-1086 (handler)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 }; }
- src/mcp/mcp-server.js:127-134 (schema)Tool schema definition including name, description, and empty input schema for 'listModels'.{ name: 'listModels', description: 'List all available DataFlood models', inputSchema: { type: 'object', properties: {} } },
- src/mcp/mcp-server.js:759-761 (registration)Dispatch/registration of the 'listModels' tool handler within the tool call switch statement.case 'listModels': result = await this.listModels(); break;
- src/mcp/index.js:425-455 (handler)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'}` }] };
- src/mcp/index.js:196-202 (schema)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: {} }