generateDataModel
Create statistical models from sample documents or text descriptions to generate realistic synthetic 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 |
|---|---|---|---|
| description | No | Natural language description of the data structure | |
| name | Yes | Name for the model | |
| samples | No | Sample documents to train the model |
Implementation Reference
- src/mcp/mcp-server.js:895-926 (handler)The primary handler function implementing the generateDataModel tool. It infers a JSON schema from provided samples using this.inferrer.inferSchema or generates from a description, saves the model to storage, caches it, and returns success info with 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:57-67 (schema)The input schema definition for the generateDataModel tool, specifying parameters: name (required), description, samples.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 in the handleToolCall switch statement dispatching to the generateDataModel handler.case 'generateDataModel': result = await this.generateDataModel(args); break;
- src/mcp/mcp-server.js:1105-1108 (helper)Helper method used by generateDataModel to generate schema from natural language description using promptAnalyzer.generateFromDescription(description) { const analysis = this.promptAnalyzer.analyze(description); return analysis.schema; }
- src/mcp/mcp-server.js:55-67 (registration)Tool metadata registration in the this.tools array, including name, description, and schema.this.tools = [ { 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'] }