generateDataModel
Create statistical models from sample documents or text descriptions to generate realistic data for MongoDB-compatible databases without actual storage.
Instructions
Create a statistical model from sample documents or a text description for data generation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name for the model | |
| description | No | Natural language description of the data structure | |
| samples | No | Sample documents to train the model |
Implementation Reference
- src/mcp/mcp-server.js:895-926 (handler)The core handler function that implements the generateDataModel tool logic. It processes input arguments to either infer a JSON schema from sample data or generate one from a description, persists the model using storage, caches it in memory, and returns a success response with model properties.async generateDataModel(args) { const { name, description, samples } = args; if (samples && samples.length > 0) { const model = this.inferrer.inferSchema(samples); model.title = name; model.description = description || `DataFlood model: ${name}`; await this.storage.saveModel(config.storage.defaultDatabase, name, model); this.models.set(name, model); return { success: true, message: `Model '${name}' created from ${samples.length} samples`, properties: Object.keys(model.properties || {}) }; } else if (description) { const model = this.generateFromDescription(description); model.title = name; await this.storage.saveModel(config.storage.defaultDatabase, name, model); this.models.set(name, model); return { success: true, message: `Model '${name}' generated from description`, properties: Object.keys(model.properties || {}) }; } else { throw new Error('Either samples or description required'); } }
- src/mcp/mcp-server.js:56-68 (schema)The input schema and metadata definition for the generateDataModel tool, used for validation and advertised via tools/list endpoint.{ name: 'generateDataModel', description: 'Generate a DataFlood model from sample data or description', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Name for the model' }, description: { type: 'string', description: 'Natural language description of the data structure' }, samples: { type: 'array', description: 'Sample documents to train the model', items: { type: 'object' } } }, required: ['name'] } },
- src/mcp/mcp-server.js:741-743 (registration)Registration and dispatch point within the handleToolCall method's switch statement that routes tool calls named 'generateDataModel' to the handler function.case 'generateDataModel': result = await this.generateDataModel(args); break;
- src/mcp/mcp-server.js:1105-1108 (helper)Supporting helper function called by the handler to generate a model schema from a natural language description using a prompt analyzer.generateFromDescription(description) { const analysis = this.promptAnalyzer.analyze(description); return analysis.schema; }
- src/mcp/index.js:125-137 (schema)Alternative input schema definition for generateDataModel in index.js tool definitions array.{ name: 'generateDataModel', description: 'Create a statistical model from sample documents or a text description for data generation', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Name for the model' }, description: { type: 'string', description: 'Natural language description of the data structure' }, samples: { type: 'array', description: 'Sample documents to train the model', items: { type: 'object' } } }, required: ['name'] } },