Skip to main content
Glama

queryModel

Generate realistic documents from statistical models using MongoDB-style queries with controls for reproducibility and randomness.

Instructions

Generate documents from a statistical model with optional query filters and generation control ($seed for reproducibility, $entropy for randomness)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modelYesModel name
queryNoMongoDB-style query. Special parameters: $seed (number) for reproducible generation, $entropy (0-1) to control randomness level
countNoNumber of documents to generate

Implementation Reference

  • Primary handler implementation for the 'queryModel' tool. Loads the model schema from storage if not cached, then generates the specified number of documents using DocumentGenerator.
    async queryModel(args) {
        const { model, query = {}, count = 10 } = args;
        
        if (!this.models.has(model)) {
            const loaded = await this.storage.getModel(config.storage.defaultDatabase, model);
            if (!loaded) {
                throw new Error(`Model '${model}' not found`);
            }
            this.models.set(model, loaded);
        }
        
        const schema = this.models.get(model);
        const documents = this.generator.generateDocuments(schema, count);
        
        return {
            model,
            count: documents.length,
            documents
        };
    }
  • Input schema definition for the 'queryModel' tool, defining parameters model (required), query (object), and count (default 10).
    {
        name: 'queryModel',
        description: 'Query a DataFlood model directly. Supports generation control via $seed and $entropy parameters in the query.',
        inputSchema: {
            type: 'object',
            properties: {
                model: { type: 'string', description: 'Model name' },
                query: { 
                    type: 'object', 
                    description: 'MongoDB-style query. Special parameters: $seed (number) for reproducible generation, $entropy (0-1) to control randomness level' 
                },
                count: { type: 'integer', description: 'Number of documents to generate', default: 10 }
            },
            required: ['model']
        }
    },
  • Registration/dispatch in the tool call handler switch statement, invoking the queryModel method.
    case 'queryModel':
        result = await this.queryModel(args);
        break;
  • Alternative inline handler for 'queryModel' tool in the SDK-based server implementation.
    case 'queryModel':
      // Check filesystem first
      let model = models.get(args.model);
      if (!model) {
        try {
          model = await storage.getModel(config.storage.defaultDatabase, args.model);
          if (model) {
            models.set(args.model, model);
          }
        } catch (error) {
          throw new Error(`Model '${args.model}' not found`);
        }
      }
      if (!model) {
        throw new Error(`Model '${args.model}' not found`);
      }
      
      const count = args.count || 10;
      const query = args.query || {};
      const seed = query.$seed;
      const entropy = query.$entropy || 0.5;
      
      // Generate documents using DataFlood - model is already the schema
      const documents = documentGenerator.generateDocuments(model, count);
      
      return {
        content: [{
          type: 'text',
          text: `Generated ${documents.length} documents from model '${args.model}'\n\nGeneration parameters:\n- Seed: ${seed || 'random'}\n- Entropy: ${entropy}\n- Query filters: ${JSON.stringify(query, null, 2)}\n\nSample documents:\n${documents.slice(0, 3).map(d => JSON.stringify(d, null, 2)).join('\n\n')}`
        }]
      };
  • Input schema definition for 'queryModel' tool in the SDK-based implementation.
    {
      name: 'queryModel',
      description: 'Generate documents from a statistical model with optional query filters and generation control ($seed for reproducibility, $entropy for randomness)',
      inputSchema: {
        type: 'object',
        properties: {
          model: { type: 'string', description: 'Model name' },
          query: { 
            type: 'object', 
            description: 'MongoDB-style query. Special parameters: $seed (number) for reproducible generation, $entropy (0-1) to control randomness level' 
          },
          count: { type: 'integer', description: 'Number of documents to generate', default: 10 }
        },
        required: ['model']
      }
    },

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