Skip to main content
Glama

generate-company

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

Instructions

Generates fake company data including names, industries, contact information, and addresses

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
countNoNumber of company records to generate
localeNoLocale for generated dataen
seedNoOptional seed for reproducible generation
includeAddressNoWhether to include address information
includeWebsiteNoWhether to include website URL
includePhoneNoWhether to include phone number
includeFoundedYearNoWhether to include founded year
includeEmployeeCountNoWhether to include employee count

Implementation Reference

  • The main handler function for the 'generate-company' tool. It parses input parameters using Zod, creates a CompanyGenerator instance, generates the requested number of company records, builds metadata, and returns an MCP-compatible response containing a text summary and a JSON resource with the generated data.
    export function handleGenerateCompany(args: unknown): Promise<{ content: unknown[] }> {
      const startTime = Date.now();
    
      try {
        // Validate and parse arguments
        const params = GenerateCompanySchema.parse(args);
    
        // Create generator
        const generator = new CompanyGenerator({
          seed: params.seed,
          locale: params.locale,
        });
    
        // Generate data
        const data =
          params.count === 1
            ? [
                generator.generate({
                  includeAddress: params.includeAddress,
                  includeWebsite: params.includeWebsite,
                  includePhone: params.includePhone,
                  includeFoundedYear: params.includeFoundedYear,
                  includeEmployeeCount: params.includeEmployeeCount,
                }),
              ]
            : generator.generateMany(params.count, {
                includeAddress: params.includeAddress,
                includeWebsite: params.includeWebsite,
                includePhone: params.includePhone,
                includeFoundedYear: params.includeFoundedYear,
                includeEmployeeCount: params.includeEmployeeCount,
              });
    
        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} company record${data.length > 1 ? 's' : ''} with seed ${params.seed}`
          : `Generated ${data.length} company record${data.length > 1 ? 's' : ''}`;
    
        return Promise.resolve({
          content: [
            {
              type: 'text',
              text: responseText,
            },
            {
              type: 'resource',
              resource: {
                uri: 'faker://companies/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 schema for validating input parameters to the generate-company tool, including count, locale, seed, and flags for optional fields like address, website, phone, founded year, and employee count.
    export const GenerateCompanySchema = z.object({
      count: z.number().min(1).max(10000).default(1).describe('Number of company 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'),
      includeWebsite: z.boolean().default(true).describe('Whether to include website URL'),
      includePhone: z.boolean().default(true).describe('Whether to include phone number'),
      includeFoundedYear: z.boolean().default(false).describe('Whether to include founded year'),
      includeEmployeeCount: z.boolean().default(false).describe('Whether to include employee count'),
    });
  • Tool metadata definition for 'generate-company', including name, description, and JSON schema derived from Zod schema for MCP tool registration.
    export const generateCompanyTool: Tool = {
      name: 'generate-company',
      description:
        'Generates fake company data including names, industries, contact information, and addresses',
      inputSchema: zodToJsonSchema(GenerateCompanySchema) as Tool['inputSchema'],
    };
  • src/index.ts:20-22 (registration)
    Registration of the generate-company tool handler with the FakerMCPServer instance in the main entry point.
    // Register User Story 1 tools: generate-person and generate-company
    server.registerTool(generatePersonTool, handleGeneratePerson);
    server.registerTool(generateCompanyTool, handleGenerateCompany);
  • CompanyGenerator class extending BaseGenerator, containing the core logic for generating single or multiple company records with faker.js, including industry selection, contact info, address, founded year, and weighted employee counts.
    export class CompanyGenerator extends BaseGenerator {
      /**
       * Creates a new CompanyGenerator instance.
       *
       * @constructor
       * @param {BaseGeneratorOptions} [options={}] - Generator configuration options
       * @example
       * ```typescript
       * const generator = new CompanyGenerator({
       *   locale: SupportedLocale.DE,
       *   seed: 12345
       * });
       * ```
       */
      constructor(options: BaseGeneratorOptions = {}) {
        super(options);
      }
    
      /**
       * Gets an industry name with locale-specific fallback.
       * Uses buzzNoun if available in the locale, otherwise falls back to generic industries.
       *
       * @private
       * @returns {string} An industry name
       * @example
       * ```typescript
       * const industry = this.getIndustry();
       * // Returns: 'Technology', 'Finance', 'Manufacturing', etc.
       * ```
       */
      private getIndustry(): string {
        try {
          return this.faker.company.buzzNoun();
        } catch {
          // Fallback to generic industries for locales without buzzNoun
          const industries = [
            'Technology',
            'Manufacturing',
            'Retail',
            'Healthcare',
            'Finance',
            'Education',
            'Consulting',
            'Real Estate',
            'Transportation',
            'Hospitality',
          ];
          return this.faker.helpers.arrayElement(industries);
        }
      }
    
      /**
       * Generates a single company record with complete business information.
       *
       * @param {CompanyGenerationOptions} [options={}] - Options controlling which fields to include
       * @returns {CompanyData} A company data object
       * @example
       * ```typescript
       * const company = generator.generate({
       *   includeAddress: true,
       *   includeWebsite: true,
       *   includeFoundedYear: true,
       *   includeEmployeeCount: true
       * });
       * // Returns: {
       * //   id: 'company_12345_0',
       * //   name: 'Acme Corporation',
       * //   industry: 'Technology',
       * //   email: 'acme@contact.com',
       * //   phone: '+1-555-987-6543',
       * //   website: 'https://acme.com',
       * //   founded: 1995,
       * //   employeeCount: 150,
       * //   address: { ... }
       * // }
       * ```
       */
      public generate(options: CompanyGenerationOptions = {}): CompanyData {
        const {
          includeAddress = true,
          includePhone = true,
          includeWebsite = true,
          includeFoundedYear = false,
          includeEmployeeCount = false,
        } = options;
    
        const companyName = this.faker.company.name();
    
        const company: CompanyData = {
          id: this.generateId('company', 0),
          name: companyName,
          industry: this.getIndustry(),
          email: this.faker.internet
            .email({
              firstName: companyName.split(' ')[0]?.toLowerCase() ?? 'info',
              lastName: 'contact',
            })
            .toLowerCase(),
        };
    
        if (includePhone) {
          company.phone = this.faker.phone.number();
        }
    
        if (includeWebsite) {
          company.website = this.faker.internet.url();
        }
    
        if (includeFoundedYear) {
          company.founded = this.faker.date
            .between({ from: '1900-01-01', to: new Date() })
            .getFullYear();
        }
    
        if (includeEmployeeCount) {
          // Generate employee count weighted towards smaller companies
          const weights = [0.5, 0.3, 0.15, 0.05]; // 50% small, 30% medium, 15% large, 5% enterprise
          const ranges = [
            { min: 1, max: 50 },
            { min: 51, max: 500 },
            { min: 501, max: 5000 },
            { min: 5001, max: 50000 },
          ];
    
          const rand = Math.random();
          let cumulative = 0;
          let range = ranges[0] ?? { min: 1, max: 50 };
    
          for (let i = 0; i < weights.length; i++) {
            cumulative += weights[i] ?? 0;
            if (rand < cumulative) {
              range = ranges[i] ?? { min: 1, max: 50 };
              break;
            }
          }
    
          company.employeeCount = this.faker.number.int({ min: range.min, max: range.max });
        }
    
        if (includeAddress) {
          company.address = {
            street: this.faker.location.streetAddress(),
            city: this.faker.location.city(),
            state: this.faker.location.state(),
            postalCode: this.faker.location.zipCode(),
            country: this.faker.location.country(),
          };
        }
    
        return company;
      }
    
      /**
       * Generates multiple company records efficiently.
       * Uses batch processing for large datasets to optimize memory usage.
       * Employee counts are weighted toward smaller companies (realistic distribution).
       *
       * @param {number} count - Number of company records to generate
       * @param {CompanyGenerationOptions} [options={}] - Options controlling which fields to include
       * @returns {CompanyData[]} Array of company data objects
       * @example
       * ```typescript
       * const companies = generator.generateMany(100, {
       *   includeAddress: true,
       *   includeWebsite: true,
       *   includeFoundedYear: true,
       *   includeEmployeeCount: true
       * });
       * console.log(`Generated ${companies.length} companies`);
       * ```
       */
      public generateMany(count: number, options: CompanyGenerationOptions = {}): CompanyData[] {
        return this.batchGenerate(count, (index) => {
          const {
            includeAddress = true,
            includePhone = true,
            includeWebsite = true,
            includeFoundedYear = false,
            includeEmployeeCount = false,
          } = options;
    
          const companyName = this.faker.company.name();
    
          const company: CompanyData = {
            id: this.generateId('company', index),
            name: companyName,
            industry: this.getIndustry(),
            email: this.faker.internet
              .email({
                firstName: companyName.split(' ')[0]?.toLowerCase() ?? 'info',
                lastName: 'contact',
              })
              .toLowerCase(),
          };
    
          if (includePhone) {
            company.phone = this.faker.phone.number();
          }
    
          if (includeWebsite) {
            company.website = this.faker.internet.url();
          }
    
          if (includeFoundedYear) {
            company.founded = this.faker.date
              .between({ from: '1900-01-01', to: new Date() })
              .getFullYear();
          }
    
          if (includeEmployeeCount) {
            const weights = [0.5, 0.3, 0.15, 0.05];
            const ranges = [
              { min: 1, max: 50 },
              { min: 51, max: 500 },
              { min: 501, max: 5000 },
              { min: 5001, max: 50000 },
            ];
    
            const rand = Math.random();
            let cumulative = 0;
            let range = ranges[0] ?? { min: 1, max: 50 };
    
            for (let i = 0; i < weights.length; i++) {
              cumulative += weights[i] ?? 0;
              if (rand < cumulative) {
                range = ranges[i] ?? { min: 1, max: 50 };
                break;
              }
            }
    
            company.employeeCount = this.faker.number.int({ min: range.min, max: range.max });
          }
    
          if (includeAddress) {
            company.address = {
              street: this.faker.location.streetAddress(),
              city: this.faker.location.city(),
              state: this.faker.location.state(),
              postalCode: this.faker.location.zipCode(),
              country: this.faker.location.country(),
            };
          }
    
          return company;
        });
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. While it states the tool generates fake data, it doesn't mention whether this is deterministic (e.g., based on seed), the format of output (e.g., JSON array), performance characteristics (e.g., rate limits for large counts), or any side effects. For a tool with 8 parameters and no annotation coverage, this is a significant gap.

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

Conciseness5/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 ('Generates fake company data') and lists key data types without unnecessary elaboration. Every word earns its place, making it easy for an agent to quickly understand the tool's function.

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

Completeness3/5

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

Given the tool's moderate complexity (8 parameters, no output schema, no annotations), the description is adequate but incomplete. It covers what data is generated but lacks details on output format, behavioral traits, and usage context. With no output schema, the description should ideally hint at return values (e.g., 'returns an array of company objects'), but it doesn't, leaving gaps for the agent.

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%, with each parameter well-documented in the schema (e.g., 'count' specifies range and default, 'locale' lists enums). The description adds minimal value beyond the schema by mentioning data types like 'addresses' (implied by 'includeAddress') and 'contact information' (implied by 'includePhone', 'includeWebsite'), but doesn't provide additional syntax or usage details. 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.

Purpose5/5

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

The description clearly states the specific action ('Generates fake company data') and enumerates the types of data produced (names, industries, contact information, addresses). It distinguishes this tool from sibling tools like 'generate-person' by specifying it generates company data rather than personal or other types of data.

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 provides no guidance on when to use this tool versus alternatives like 'generate-custom' or 'generate-dataset'. It doesn't mention any prerequisites, constraints, or scenarios where this tool is preferred over others, leaving the agent to infer usage context.

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

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