Skip to main content
Glama
QianJue-CN

Random.org MCP Server

by QianJue-CN

generateDecimalFractions

Generate true random decimal fractions between 0 and 1 for applications requiring statistically random data, with customizable quantity and precision.

Instructions

Generate true random decimal fractions between 0 and 1

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nYesNumber of decimal fractions to generate (1-10,000)
decimalPlacesYesNumber of decimal places (1-20)
replacementNoAllow replacement (duplicates)

Implementation Reference

  • The primary MCP tool handler function that executes the generateDecimalFractions tool call by delegating to the RandomOrgClient and formatting the response as MCP-standard content.
    private async handleGenerateDecimalFractions(args: any) { const result = await this.randomOrgClient.generateDecimalFractions(args); return { content: [ { type: 'text', text: JSON.stringify({ data: result.random.data, completionTime: result.random.completionTime, bitsUsed: result.bitsUsed, bitsLeft: result.bitsLeft, requestsLeft: result.requestsLeft, advisoryDelay: result.advisoryDelay, }, null, 2), }, ], }; }
  • src/server.ts:122-148 (registration)
    Tool registration in the ListTools response, defining the tool's name, description, and input schema for validation.
    { name: 'generateDecimalFractions', description: 'Generate true random decimal fractions between 0 and 1', inputSchema: { type: 'object', properties: { n: { type: 'number', description: 'Number of decimal fractions to generate (1-10,000)', minimum: 1, maximum: 10000, }, decimalPlaces: { type: 'number', description: 'Number of decimal places (1-20)', minimum: 1, maximum: 20, }, replacement: { type: 'boolean', description: 'Allow replacement (duplicates)', default: true, }, }, required: ['n', 'decimalPlaces'], }, },
  • JSON schema for input validation of the generateDecimalFractions tool parameters.
    inputSchema: { type: 'object', properties: { n: { type: 'number', description: 'Number of decimal fractions to generate (1-10,000)', minimum: 1, maximum: 10000, }, decimalPlaces: { type: 'number', description: 'Number of decimal places (1-20)', minimum: 1, maximum: 20, }, replacement: { type: 'boolean', description: 'Allow replacement (duplicates)', default: true, }, }, required: ['n', 'decimalPlaces'], },
  • Helper method in RandomOrgClient that handles parameter validation and makes the actual API request to random.org.
    async generateDecimalFractions(params: DecimalParams): Promise<DecimalResult> { this.validateDecimalParams(params); return this.makeRequest<DecimalResult>('generateDecimalFractions', params); }
  • Parameter validation helper specifically for decimal fractions inputs.
    private validateDecimalParams(params: DecimalParams): void { if (params.n < 1 || params.n > 10000) { throw new Error('n must be between 1 and 10,000'); } if (params.decimalPlaces < 1 || params.decimalPlaces > 20) { throw new Error('decimalPlaces must be between 1 and 20'); } }

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/QianJue-CN/TRUERandomMCP'

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