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
| Name | Required | Description | Default |
|---|---|---|---|
| n | Yes | Number of decimal fractions to generate (1-10,000) | |
| decimalPlaces | Yes | Number of decimal places (1-20) | |
| replacement | No | Allow replacement (duplicates) |
Implementation Reference
- src/server.ts:339-356 (handler)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'], }, },
- src/server.ts:125-147 (schema)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'], },
- src/randomOrgClient.ts:93-96 (helper)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); }
- src/randomOrgClient.ts:159-166 (helper)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'); } }