Skip to main content
Glama

generate-person

Generate realistic fake person data for testing and development, including names, contact details, and addresses with customizable options.

Instructions

Generates fake person data including names, emails, phone numbers, and addresses

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
countNoNumber of person records to generate
localeNoLocale for generated dataen
seedNoOptional seed for reproducible generation
includeAddressNoWhether to include address information
includePhoneNoWhether to include phone number
includeDateOfBirthNoWhether to include date of birth

Implementation Reference

  • Handler function for the generate-person MCP tool. Validates input parameters using Zod schema, generates fake person data using PersonGenerator (single or batch), computes metadata, and returns an MCP response with text summary and JSON resource containing the data.
    export function handleGeneratePerson(args: unknown): Promise<{ content: unknown[] }> { const startTime = Date.now(); try { // Validate and parse arguments const params = GeneratePersonSchema.parse(args); // Create generator const generator = new PersonGenerator({ seed: params.seed, locale: params.locale, }); // Generate data const data = params.count === 1 ? [ generator.generate({ includeAddress: params.includeAddress, includePhone: params.includePhone, includeDateOfBirth: params.includeDateOfBirth, }), ] : generator.generateMany(params.count, { includeAddress: params.includeAddress, includePhone: params.includePhone, includeDateOfBirth: params.includeDateOfBirth, }); const generationTimeMs = Date.now() - startTime; // Build response const metadata = { count: data.length, seed: generator.getSeed(), locale: generator.getLocale(), generationTimeMs, }; const responseText = params.seed ? `Generated ${data.length} person record${data.length > 1 ? 's' : ''} with seed ${params.seed}` : `Generated ${data.length} person record${data.length > 1 ? 's' : ''}`; return Promise.resolve({ content: [ { type: 'text', text: responseText, }, { type: 'resource', resource: { uri: 'faker://persons/generated', mimeType: 'application/json', text: JSON.stringify({ data, metadata }, null, 2), }, }, ], }); } catch (error) { if (error instanceof z.ZodError) { throw new Error( `Invalid parameters: ${error.errors.map((e) => `${e.path.join('.')}: ${e.message}`).join(', ')}` ); } throw error; } }
  • Zod validation schema defining input parameters for the generate-person tool, including count, locale, seed, and flags for including address, phone, and date of birth.
    export const GeneratePersonSchema = z.object({ count: z.number().min(1).max(10000).default(1).describe('Number of person records to generate'), locale: z .nativeEnum(SupportedLocale) .default(SupportedLocale.EN) .describe('Locale for generated data'), seed: z.number().optional().describe('Optional seed for reproducible generation'), includeAddress: z.boolean().default(true).describe('Whether to include address information'), includePhone: z.boolean().default(true).describe('Whether to include phone number'), includeDateOfBirth: z.boolean().default(false).describe('Whether to include date of birth'), });
  • MCP Tool definition object for generate-person, including name, description, and input schema derived from Zod schema using zod-to-json-schema.
    export const generatePersonTool: Tool = { name: 'generate-person', description: 'Generates fake person data including names, emails, phone numbers, and addresses', inputSchema: zodToJsonSchema(GeneratePersonSchema) as Tool['inputSchema'], };
  • src/index.ts:21-21 (registration)
    Registration of the generate-person tool with the FakerMCPServer by passing the tool definition and handler function.
    server.registerTool(generatePersonTool, handleGeneratePerson);

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