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

  • src/server.ts:122-148 (registration)
    Tool registration in the ListTools response, defining name, description, and input schema for generateDecimalFractions.
    { 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'], }, },
  • MCP server handler that executes the generateDecimalFractions tool by calling RandomOrgClient and formatting the result as MCP response 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), }, ], }; }
  • TypeScript interface defining the input parameters for generateDecimalFractions, matching the inputSchema.
    export interface DecimalParams { n: number; decimalPlaces: number; replacement?: boolean; }
  • RandomOrgClient method implementing the API call for generateDecimalFractions after validation.
    async generateDecimalFractions(params: DecimalParams): Promise<DecimalResult> { this.validateDecimalParams(params); return this.makeRequest<DecimalResult>('generateDecimalFractions', params); }
  • Validation helper function ensuring input parameters for generateDecimalFractions are within allowed ranges.
    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