Skip to main content
Glama

generate-dataset

Create structured datasets with realistic mock data for testing databases, APIs, and development scenarios. Supports multiple entity types, relationships, and referential integrity.

Instructions

Generate a structured dataset with multiple related entities and referential integrity. Supports person, company, and custom entity types with one-to-many and many-to-many relationships. Perfect for creating test databases, mock APIs, and complex data scenarios.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
schemaYes
seedNo
localeNoen

Implementation Reference

  • The handler function for the 'generate-dataset' tool. It validates the input parameters using Zod, checks the dataset schema for validity, creates a DatasetGenerator instance, generates the dataset, and returns it in MCP response format.
    export function handleGenerateDataset(params: unknown) { try { // Validate parameters const validatedParams = GenerateDatasetParamsSchema.parse(params); // Additional schema validation (referential integrity, circular dependencies) const schemaValidation = validateDatasetSchema(validatedParams.schema); if (!schemaValidation.valid) { throw new Error(`Invalid dataset schema: ${schemaValidation.errors.join(', ')}`); } // Create generator const generator = new DatasetGenerator({ seed: validatedParams.seed, locale: validatedParams.locale, }); // Generate dataset const result = generator.generateDataset(validatedParams.schema); // Log generation (no console.log, following linter rules - will log in server.ts instead) // Return response return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { // Error handling if (error instanceof z.ZodError) { const errorMessage = `Validation error: ${error.errors.map((e) => `${e.path.join('.')}: ${e.message}`).join(', ')}`; // Log error (will be handled by server) throw new Error(errorMessage); } if (error instanceof Error) { // Log error (will be handled by server) throw error; } // Log unknown error (will be handled by server) throw new Error('Unknown error occurred during dataset generation'); } }
  • Zod schema for validating tool input parameters (GenerateDatasetParamsSchema), type inference, and the MCP Tool object definition including the JSON inputSchema derived from Zod.
    export const GenerateDatasetParamsSchema = z.object({ schema: DatasetSchemaSchema, seed: z.number().int().optional(), locale: z.nativeEnum(SupportedLocale).optional().default(SupportedLocale.EN), }); /** * Type definition for generate-dataset parameters, inferred from Zod schema. * * @typedef {z.infer<typeof GenerateDatasetParamsSchema>} GenerateDatasetParams */ export type GenerateDatasetParams = z.infer<typeof GenerateDatasetParamsSchema>; /** * MCP Tool definition for dataset generation with multiple related entities. * Supports complex data scenarios with referential integrity. * * @constant * @type {Tool} * @property {string} name - Tool identifier * @property {string} description - Human-readable tool description * @property {Object} inputSchema - JSON Schema for tool inputs */ export const generateDatasetTool: Tool = { name: 'generate-dataset', description: 'Generate a structured dataset with multiple related entities and referential integrity. ' + 'Supports person, company, and custom entity types with one-to-many and many-to-many relationships. ' + 'Perfect for creating test databases, mock APIs, and complex data scenarios.', inputSchema: zodToJsonSchema(GenerateDatasetParamsSchema) as Tool['inputSchema'], };
  • src/index.ts:24-28 (registration)
    Registration of the 'generate-dataset' tool on the MCP server using the generateDatasetTool definition and a wrapper around the handleGenerateDataset handler.
    // Register User Story 2 tool: generate-dataset server.registerTool(generateDatasetTool, async (args) => { await Promise.resolve(); return handleGenerateDataset(args); });

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/funsjanssen/faker-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server