Skip to main content
Glama
turlockmike

MCP Rand

by turlockmike

generate_gaussian

Produce a random number based on a Gaussian (normal) distribution between 0 and 1 using MCP Rand's utility for statistical modeling or simulation needs.

Instructions

Generate a random number following a Gaussian (normal) distribution between 0 and 1

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'generate_gaussian' tool. It calls the internal generateGaussian() helper and returns the result as MCP tool content (text).
    export const generateGaussianHandler = async (
      _request: CallToolRequest
    ): Promise<CallToolResult> => {
      const gaussian = generateGaussian();
      
      return {
        content: [
          {
            type: 'text',
            text: gaussian.toString()
          }
        ]
      };
    };
  • Tool schema/specification defining name, description, and empty input schema for no parameters.
    export const toolSpec = {
      name: 'generate_gaussian',
      description: 'Generate a random number following a Gaussian (normal) distribution between 0 and 1',
      inputSchema: {
        type: 'object' as const,
        properties: {}
      }
    };
  • src/index.ts:21-21 (registration)
    Registers the generateGaussianHandler under the 'tools/call' method for the tool name 'generate_gaussian' in the MCP server.
    registry.register('tools/call', 'generate_gaussian', generateGaussianHandler as Handler);
  • Core helper implementing Box-Muller transform with error function to generate Gaussian random number normalized to [0,1].
    function generateGaussian(): number {
      let u1 = 0;
      let u2 = 0;
      
      // Avoid u1 being zero
      do {
        u1 = Math.random();
        u2 = Math.random();
      } while (u1 <= Number.EPSILON);
    
      const z0 = Math.sqrt(-2.0 * Math.log(u1)) * Math.cos(2.0 * Math.PI * u2);
      
      // Convert from standard normal distribution (mean 0, std dev 1)
      // to a value between 0 and 1 using the error function (erf)
      // We add 1 and divide by 2 to shift from [-1,1] to [0,1]
      const normalized = (erf(z0 / Math.SQRT2) + 1) / 2;
      
      // Clamp to [0,1] in case of floating point errors
      return Math.max(0, Math.min(1, normalized));
    }
  • Approximation of the error function (erf) used in generateGaussian for normalizing the distribution.
    // Abramowitz and Stegun approximation (maximum error: 1.5×10−7)
    function erf(x: number): number {
      const sign = Math.sign(x);
      x = Math.abs(x);
    
      const p = 0.3275911;
      const a1 = 0.254829592;
      const a2 = -0.284496736;
      const a3 = 1.421413741;
      const a4 = -1.453152027;
      const a5 = 1.061405429;
    
      const t = 1.0 / (1.0 + p * x);
      const poly = t * (a1 + t * (a2 + t * (a3 + t * (a4 + t * a5))));
    
      return sign * (1 - poly * Math.exp(-x * x));
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses the tool's behavior by specifying the distribution type and range, but lacks details on randomness source, statistical parameters (e.g., mean, standard deviation), or output format. This is adequate for a simple tool but leaves gaps in behavioral context.

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 key action and constraints without any wasted words. Every element ('Generate', 'random number', 'Gaussian distribution', 'between 0 and 1') contributes directly to understanding the tool's purpose.

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

Completeness4/5

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

Given the tool's simplicity (0 parameters, no output schema, no annotations), the description is nearly complete. It specifies the distribution and range, but lacks output details (e.g., numeric format, precision) and doesn't mention if the range is inclusive or exclusive, leaving minor gaps for a fully informed agent.

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 0 parameters with 100% schema description coverage, so no parameter documentation is needed. The description compensates by implicitly explaining the lack of parameters through its self-contained specification, earning a baseline score above 3 for clarity in a parameterless context.

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 ('Generate a random number') and the statistical distribution ('following a Gaussian (normal) distribution'), with explicit range constraints ('between 0 and 1'). It distinguishes itself from sibling tools like 'generate_random_number' by specifying the distribution type and range.

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

Usage Guidelines4/5

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

The description implies usage context through the range specification ('between 0 and 1'), which suggests when this tool is appropriate versus alternatives. However, it doesn't explicitly state when not to use it or name specific alternatives among siblings like 'generate_random_number' for uniform distributions.

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

Related 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/turlockmike/mcp-rand'

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