Skip to main content
Glama
dh1789

My First MCP

by dh1789

get_random_number

Generate random integers within a specified range for applications requiring unpredictable values, such as simulations, games, or data sampling.

Instructions

지정한 범위 내에서 랜덤 정수를 생성합니다.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
minYes최소값 (정수)
maxYes최대값 (정수)
countNo생성할 숫자 개수 (1-10). 기본값: 1

Implementation Reference

  • The MCP tool handler function that receives validated inputs, calls the core generateRandomNumbers helper, handles errors, and returns formatted text response.
    async ({ min, max, count }) => {
      const result = generateRandomNumbers(min, max, count || 1);
    
      if (result.isError) {
        return {
          content: [
            {
              type: "text",
              text: result.errorMessage!,
            },
          ],
          isError: true,
        };
      }
    
      const n = result.numbers.length;
      const resultText =
        n === 1
          ? `랜덤 숫자 (${result.min}~${result.max}): ${result.numbers[0]}`
          : `랜덤 숫자 ${n}개 (${result.min}~${result.max}): ${result.numbers.join(", ")}`;
    
      return {
        content: [
          {
            type: "text",
            text: resultText,
          },
        ],
      };
    }
  • Core pure function generateRandomNumbers that implements the random number generation logic using Math.random(). Validates min <= max, generates up to 10 random integers inclusive.
    export function generateRandomNumbers(
      min: number,
      max: number,
      count: number = 1
    ): RandomResult {
      if (min > max) {
        return {
          numbers: [],
          min,
          max,
          isError: true,
          errorMessage: "오류: 최소값이 최대값보다 큽니다.",
        };
      }
    
      const numbers: number[] = [];
      for (let i = 0; i < count; i++) {
        const randomNum = Math.floor(Math.random() * (max - min + 1)) + min;
        numbers.push(randomNum);
      }
    
      return {
        numbers,
        min,
        max,
        isError: false,
      };
    }
  • Zod schema for tool parameters: min (int), max (int), count (int 1-10 optional).
    {
      min: z.number().int().describe("최소값 (정수)"),
      max: z.number().int().describe("최대값 (정수)"),
      count: z
        .number()
        .int()
        .min(1)
        .max(10)
        .optional()
        .describe("생성할 숫자 개수 (1-10). 기본값: 1"),
    },
  • src/index.ts:165-209 (registration)
    server.tool call that registers 'get_random_number' with name, description, input schema, and handler function.
    server.tool(
      "get_random_number",
      "지정한 범위 내에서 랜덤 정수를 생성합니다.",
      {
        min: z.number().int().describe("최소값 (정수)"),
        max: z.number().int().describe("최대값 (정수)"),
        count: z
          .number()
          .int()
          .min(1)
          .max(10)
          .optional()
          .describe("생성할 숫자 개수 (1-10). 기본값: 1"),
      },
      async ({ min, max, count }) => {
        const result = generateRandomNumbers(min, max, count || 1);
    
        if (result.isError) {
          return {
            content: [
              {
                type: "text",
                text: result.errorMessage!,
              },
            ],
            isError: true,
          };
        }
    
        const n = result.numbers.length;
        const resultText =
          n === 1
            ? `랜덤 숫자 (${result.min}~${result.max}): ${result.numbers[0]}`
            : `랜덤 숫자 ${n}개 (${result.min}~${result.max}): ${result.numbers.join(", ")}`;
    
        return {
          content: [
            {
              type: "text",
              text: resultText,
            },
          ],
        };
      }
    );
  • TypeScript interface defining the return type RandomResult for the helper function.
    export interface RandomResult {
      numbers: number[];
      min: number;
      max: number;
      isError: boolean;
      errorMessage?: string;
    }
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. It states the tool generates random integers but does not explain key behaviors like whether the generation is deterministic, the distribution of randomness, error handling for invalid ranges, or output format. This leaves significant gaps for an agent to understand how to use it effectively.

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 in Korean that directly states the tool's function without any unnecessary words. It is appropriately sized and front-loaded, making it easy to understand at a glance.

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 lack of annotations and output schema, the description is incomplete. It does not cover behavioral aspects like randomness properties, error cases, or return values, which are crucial for a tool with parameters and no structured output documentation. This makes it inadequate for full contextual understanding.

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 clear descriptions for 'min', 'max', and 'count' parameters. The description adds no additional semantic information beyond what the schema provides, such as explaining range inclusivity or the effect of 'count'. Baseline 3 is appropriate as the schema does the heavy lifting.

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 tool's purpose: '지정한 범위 내에서 랜덤 정수를 생성합니다' (generates random integers within a specified range). It specifies the verb '생성합니다' (generates) and resource '랜덤 정수' (random integers), but does not distinguish it from sibling tools like 'calculate' or 'get_current_time', which serve different purposes.

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. It does not mention any context, prerequisites, or exclusions, such as when to choose this over other mathematical or data generation tools in the sibling list.

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/dh1789/my-first-mcp'

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