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
| Name | Required | Description | Default |
|---|---|---|---|
| model | Yes | Model name | |
| query | No | MongoDB-style query. Special parameters: $seed (number) for reproducible generation, $entropy (0-1) to control randomness level | |
| count | No | Number of documents to generate |
Implementation Reference
- src/mcp/mcp-server.js:1012-1031 (handler)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 }; }
- src/mcp/mcp-server.js:99-114 (schema)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'] } },
- src/mcp/mcp-server.js:753-755 (registration)Registration/dispatch in the tool call handler switch statement, invoking the queryModel method.case 'queryModel': result = await this.queryModel(args); break;
- src/mcp/index.js:378-408 (handler)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')}` }] };
- src/mcp/index.js:168-183 (schema)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'] } },