Skip to main content
Glama
SufyaanKhateeb

User Management MCP Server

create-random-user

Generate fake user data for testing user management systems. This tool creates random user profiles with realistic information to simulate real users in development or testing environments.

Instructions

Create a random user with fake data

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler function that generates random user data using LLM sampling, parses the JSON response, and creates the user via the createUser helper function.
    async () => {
      const res = await server.server.request(
        {
          method: "sampling/createMessage",
          params: {
            messages: [
              {
                role: "user",
                content: {
                  type: "text",
                  text: "Generate fake user data. The user should have a realistic name, email, address, age, and phone number. Return this data as a JSON object with no other text or formatter so it can be used with JSON.parse.",
                },
              },
            ],
            maxTokens: 1024,
          },
        },
        CreateMessageResultSchema
      )
    
      if (res.content.type !== "text") {
        return {
          content: [{ type: "text", text: "Failed to generate user data" }],
        }
      }
    
      try {
        const fakeUser = JSON.parse(
          res.content.text
            .trim()
            .replace(/^```json/, "")
            .replace(/```$/, "")
            .trim()
        )
    
        const id = await createUser(fakeUser)
        return {
          content: [{ type: "text", text: `User ${id} created successfully` }],
        }
      } catch {
        return {
          content: [{ type: "text", text: "Failed to generate user data" }],
        }
      }
    }
  • src/server.ts:123-178 (registration)
    Registration of the create-random-user tool on the MCP server, specifying description, metadata, and inline handler.
    server.tool(
      "create-random-user",
      "Create a random user with fake data",
      {
        title: "Create Random User",
        readOnlyHint: false,
        destructiveHint: false,
        idempotentHint: false,
        openWorldHint: true,
      },
      async () => {
        const res = await server.server.request(
          {
            method: "sampling/createMessage",
            params: {
              messages: [
                {
                  role: "user",
                  content: {
                    type: "text",
                    text: "Generate fake user data. The user should have a realistic name, email, address, age, and phone number. Return this data as a JSON object with no other text or formatter so it can be used with JSON.parse.",
                  },
                },
              ],
              maxTokens: 1024,
            },
          },
          CreateMessageResultSchema
        )
    
        if (res.content.type !== "text") {
          return {
            content: [{ type: "text", text: "Failed to generate user data" }],
          }
        }
    
        try {
          const fakeUser = JSON.parse(
            res.content.text
              .trim()
              .replace(/^```json/, "")
              .replace(/```$/, "")
              .trim()
          )
    
          const id = await createUser(fakeUser)
          return {
            content: [{ type: "text", text: `User ${id} created successfully` }],
          }
        } catch {
          return {
            content: [{ type: "text", text: "Failed to generate user data" }],
          }
        }
      }
    )
  • Helper function used by create-random-user (and create-user) to persist new user data to users.json file.
    async function createUser(params: { name: string; email: string; address: string; age: number; phone: string }) {
        const users = await import("./data/users.json", { with: { type: "json" } }).then((m) => m.default);
        const newId = users.length + 1;
        const newUsers = [...users, { id: newId, ...params }];
        writeFileSync("./src/data/users.json", JSON.stringify(newUsers, null, 2));
        return newId;
    }
Behavior3/5

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

Annotations already indicate this is a write operation (readOnlyHint: false) and non-destructive (destructiveHint: false). The description adds that it creates 'fake data', which provides useful context about the nature of the data generated. However, it doesn't elaborate on what 'random' entails or any rate limits or permissions required.

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 directly states the tool's purpose without any unnecessary words. It's perfectly front-loaded and wastes no space.

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 has no parameters and annotations cover basic behavioral traits, the description is adequate but minimal. It doesn't explain what 'random' means, what fields are generated, or provide any output information (though there's no output schema). For a creation tool, more detail about the generated user would be helpful.

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

Parameters4/5

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

With 0 parameters and 100% schema description coverage, the baseline is 4. The description doesn't need to explain parameters, and it appropriately doesn't attempt to do so.

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

Purpose4/5

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

The description clearly states the verb ('create') and resource ('random user with fake data'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from its sibling 'create-user' beyond implying the randomness aspect.

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 the sibling 'create-user' tool. There's no mention of alternatives, prerequisites, or specific contexts where this tool is preferred over creating a real user.

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/SufyaanKhateeb/MCP'

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