Skip to main content
Glama

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
NameRequiredDescriptionDefault
nameYesName for the model
descriptionNoNatural language description of the data structure
samplesNoSample documents to train the model

Implementation Reference

  • 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');
        }
    }
  • 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']
        }
    },
  • 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;
  • 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;
    }
  • 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']
      }
    },

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