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']
      }
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions generation control features ($seed, $entropy) but doesn't cover critical aspects like required permissions, rate limits, error handling, or what 'generate documents' entails operationally (e.g., creation vs. simulation).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose. However, it could be slightly more structured by separating purpose from parameter highlights for better readability.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (statistical model generation with nested query objects), no annotations, and no output schema, the description is incomplete. It doesn't explain return values, error cases, or behavioral nuances, leaving significant gaps for an AI agent to infer usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters. The description adds minimal value by mentioning $seed and $entropy in the query parameter, but this is redundant with the schema's description of the query object. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Generate') and resource ('documents from a statistical model'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'generateDataModel' or 'trainModel', which might have overlapping domains.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description mentions optional query filters and generation control, but provides no guidance on when to use this tool versus alternatives like 'generateDataModel' or 'trainModel'. It lacks explicit when/when-not instructions or prerequisites.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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