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;
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A3.9/5.0
Behavior3/5

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

Annotations already indicate readOnly=false, destructive=false, and idempotent=false. The description adds that the data is fake, but it does not disclose other behavioral traits such as what side effects occur, whether the user is persisted, or what the return value contains. No contradiction with annotations.

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?

One short, front-loaded sentence communicates the essential purpose without any redundant words or unnecessary detail.

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?

The tool is simple (no parameters), but there is no output schema and the description does not explain what the tool returns (e.g., the generated user's email, password, ID). This leaves a clear gap for an agent trying to use the result.

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?

The tool has zero parameters, so the baseline for this dimension is 4. The description correctly says nothing about parameters, and the empty input schema is fully consistent.

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 action ('Create'), the resource ('random user'), and the distinguishing characteristic ('with fake data'). This differentiates it from the sibling tool 'create-user', which presumably creates a real or specific user.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies a usage context (generating fake/test data) through the words 'random user with fake data', but it does not explicitly say when to use this tool versus the sibling 'create-user', nor does it mention any exclusions or prerequisites.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools