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

  • The handler function that executes the generate-person tool logic. It parses arguments with the Zod schema, instantiates PersonGenerator, generates fake person data based on parameters, adds metadata, and returns an MCP-formatted response containing a text summary and a JSON resource.
    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 all input parameters for the generate-person tool, including count, locale, seed, and inclusion flags.
    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'), });
  • Definition of the MCP Tool object for generate-person, providing the name, description, and input JSON schema converted from Zod.
    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)
    Explicit registration of the generate-person tool definition and handler function with the FakerMCPServer instance.
    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