Skip to main content
Glama
rycid

RandomUser MCP Server

by rycid

get_multiple_users

Generate multiple random user profiles with customizable attributes like gender, nationality, and data format for testing or development purposes.

Instructions

Get multiple random users

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
countYesNumber of users to generate
genderNo
nationalityNo
nationalityWeightsNo
fieldsNo
formatNo
passwordNo

Implementation Reference

  • The main handler function that implements the get_multiple_users tool. It constructs API parameters based on input args, makes multiple requests to randomuser.me API for different gender/nationality combinations to fulfill the requested count, collects results, and returns formatted output.
    private async handleGetMultipleUsers(args: any) {
      try {
        const results = [];
        const params: any = {};
    
        // Add field parameters
        this.addFieldParams(params, args);
    
        if (args.password) {
          const charsets = args.password.charsets?.join(',') || 'upper,lower,number';
          params.password = args.password.maxLength ?
            `${charsets},${args.password.minLength || 8}-${args.password.maxLength}` :
            `${charsets},${args.password.minLength || 8}`;
        }
    
        // Make one API call per requested nationality+gender combination
        for (const gender of ['female', 'male']) {
          if (args.gender && args.gender !== gender) continue;
          
          params.gender = gender;
          
          // Handle single nationality or array of nationalities
          const nationalities = Array.isArray(args.nationality) 
            ? args.nationality 
            : [args.nationality];
    
          for (const nat of nationalities) {
            params.nat = nat;
            
            const count = this.calculateCountForNationalityAndGender(args, nat, gender);
            if (count === 0) continue;
            
            params.results = count;
            
            const response = await this.axiosInstance.get('', { params });
            results.push(...response.data.results);
          }
        }
    
        return this.formatResults(results, args.format);
      } catch (error) {
        if (axios.isAxiosError(error)) {
          throw new McpError(
            ErrorCode.InternalError,
            `API Error: ${error.response?.data.error || error.message}`
          );
        }
        throw error;
      }
    }
  • Input schema definition for the get_multiple_users tool, specifying parameters like count (required), gender, nationality (single or array), weights, fields, format, and password options.
    {
      name: 'get_multiple_users',
      description: 'Get multiple random users',
      inputSchema: {
        type: 'object',
        properties: {
          count: {
            type: 'number',
            minimum: 1,
            maximum: 5000,
            description: 'Number of users to generate'
          },
          gender: {
            type: 'string',
            enum: ['male', 'female']
          },
          nationality: {
            oneOf: [
              {
                type: 'string',
                enum: NATIONALITIES
              },
              {
                type: 'array',
                items: {
                  type: 'string',
                  enum: NATIONALITIES
                }
              }
            ]
          },
          nationalityWeights: {
            type: 'object',
            patternProperties: {
              "^[A-Z]{2}$": {
                type: 'number',
                minimum: 0,
                maximum: 1
              }
            }
          },
          fields: {
            type: 'object',
            properties: this.getFieldProperties()
          },
          format: this.getFormatOptionsSchema(),
          password: {
            type: 'object',
            properties: this.getPasswordOptionsSchema()
          }
        },
        required: ['count']
      }
    }
  • src/index.ts:179-191 (registration)
    Registration of tool call handler via setRequestHandler for CallToolRequestSchema, including the switch case that dispatches 'get_multiple_users' calls to handleGetMultipleUsers.
    this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
      switch (request.params.name) {
        case 'get_random_user':
          return this.handleGetRandomUser(request.params.arguments);
        case 'get_multiple_users':
          return this.handleGetMultipleUsers(request.params.arguments);
        default:
          throw new McpError(
            ErrorCode.MethodNotFound,
            `Unknown tool: ${request.params.name}`
          );
      }
    });
  • src/index.ts:90-176 (registration)
    Tool list registration in ListToolsRequestSchema handler, where get_multiple_users is included in the returned tools array with its schema.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [
        {
          name: 'get_random_user',
          description: 'Get a single random user',
          inputSchema: {
            type: 'object',
            properties: {
              gender: {
                type: 'string',
                enum: ['male', 'female'],
                description: 'Filter results by gender'
              },
              nationality: {
                type: 'string',
                enum: NATIONALITIES,
                description: 'Specify nationality'
              },
              fields: {
                type: 'object',
                description: 'Specify which fields to include',
                properties: this.getFieldProperties()
              },
              format: this.getFormatOptionsSchema(),
              password: {
                type: 'object',
                properties: this.getPasswordOptionsSchema()
              }
            }
          }
        },
        {
          name: 'get_multiple_users',
          description: 'Get multiple random users',
          inputSchema: {
            type: 'object',
            properties: {
              count: {
                type: 'number',
                minimum: 1,
                maximum: 5000,
                description: 'Number of users to generate'
              },
              gender: {
                type: 'string',
                enum: ['male', 'female']
              },
              nationality: {
                oneOf: [
                  {
                    type: 'string',
                    enum: NATIONALITIES
                  },
                  {
                    type: 'array',
                    items: {
                      type: 'string',
                      enum: NATIONALITIES
                    }
                  }
                ]
              },
              nationalityWeights: {
                type: 'object',
                patternProperties: {
                  "^[A-Z]{2}$": {
                    type: 'number',
                    minimum: 0,
                    maximum: 1
                  }
                }
              },
              fields: {
                type: 'object',
                properties: this.getFieldProperties()
              },
              format: this.getFormatOptionsSchema(),
              password: {
                type: 'object',
                properties: this.getPasswordOptionsSchema()
              }
            },
            required: ['count']
          }
        }
      ]
    }));
  • Helper function used by the handler to compute the exact count of users to request for each nationality-gender pair, respecting filters and weights.
    private calculateCountForNationalityAndGender(
      args: any,
      nationality: string,
      gender: string
    ): number {
      if (!args.nationality) return 0;
      if (args.gender && args.gender !== gender) return 0;
      
      const totalCount = args.count || 0;
      const weights = args.nationalityWeights || {};
      
      if (!Array.isArray(args.nationality)) {
        return nationality === args.nationality ? totalCount : 0;
      }
      
      if (!args.nationality.includes(nationality)) return 0;
      
      const natWeight = weights[nationality] || (1 / args.nationality.length);
      const genderRatio = args.gender ? 1 : 0.5; // If gender specified use full count, else split 50/50
      
      return Math.round(totalCount * natWeight * genderRatio);
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. 'Get multiple random users' implies a read operation but doesn't specify whether this generates synthetic data, queries a database, or has side effects. It lacks critical behavioral context like rate limits, authentication needs, data freshness, or what 'random' entails (e.g., uniform distribution, seed control). The description is insufficient for a tool with 7 parameters and complex nested structures.

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 extremely concise at just three words, with zero wasted text. It's front-loaded and to the point, though this brevity comes at the cost of completeness. Every word ('Get', 'multiple', 'random', 'users') contributes directly to the core purpose.

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

Completeness2/5

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

Given the tool's complexity (7 parameters with nested objects, 14% schema coverage, no output schema, and no annotations), the description is severely incomplete. It doesn't address what the tool returns, how 'random' generation works, the scope of user data, or the interplay between parameters like 'gender', 'nationality', and 'fields'. For a data generation tool with rich configuration options, this minimal description leaves critical gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is only 14%, meaning most parameters lack documentation in the schema. The description 'Get multiple random users' adds minimal semantic value—it only hints at the 'count' parameter for 'multiple' and 'random' which might relate to generation logic. It doesn't explain the purpose of complex parameters like 'nationalityWeights', 'fields', 'format', or 'password', leaving the agent to guess their roles from schema structure alone.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

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

The description 'Get multiple random users' states the basic action (get) and resource (users) with the qualifier 'multiple random', but it's vague about what 'random' means in this context and doesn't distinguish from the sibling tool 'get_random_user'. It provides a minimal purpose statement without specificity about the source or nature of these users.

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. There's no mention of the sibling tool 'get_random_user', nor any context about appropriate use cases, prerequisites, or constraints. The agent must infer usage solely from the tool name and parameters.

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/rycid/randomuserMCP'

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