generateBlobs
Generate true random binary data for cryptographic applications, simulations, or testing by specifying quantity and size parameters with output in base64 or hex format.
Instructions
Generate true random binary data
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| n | Yes | Number of blobs to generate (1-100) | |
| size | Yes | Size of each blob in bytes (1-1,048,576) | |
| format | No | Output format | base64 |
Implementation Reference
- src/server.ts:227-254 (registration)Tool registration in listTools handler, defining name, description, and input schema for generateBlobs.{ name: 'generateBlobs', description: 'Generate true random binary data', inputSchema: { type: 'object', properties: { n: { type: 'number', description: 'Number of blobs to generate (1-100)', minimum: 1, maximum: 100, }, size: { type: 'number', description: 'Size of each blob in bytes (1-1,048,576)', minimum: 1, maximum: 1048576, }, format: { type: 'string', description: 'Output format', enum: ['base64', 'hex'], default: 'base64', }, }, required: ['n', 'size'], }, },
- src/server.ts:415-432 (handler)MCP server handler for the generateBlobs tool. Invokes RandomOrgClient.generateBlobs and formats the response as MCP content block.private async handleGenerateBlobs(args: any) { const result = await this.randomOrgClient.generateBlobs(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/types.ts:154-158 (schema)TypeScript interface defining the input parameters (BlobParams) for the generateBlobs API call.export interface BlobParams { n: number; size: number; format?: 'base64' | 'hex'; }
- src/randomOrgClient.ts:113-116 (helper)RandomOrgClient method that performs input validation and makes the JSON-RPC request to Random.org API for generating blobs.async generateBlobs(params: BlobParams): Promise<BlobResult> { this.validateBlobParams(params); return this.makeRequest<BlobResult>('generateBlobs', params); }
- src/randomOrgClient.ts:195-205 (helper)Input validation helper for BlobParams used in generateBlobs.private validateBlobParams(params: BlobParams): void { if (params.n < 1 || params.n > 100) { throw new Error('n must be between 1 and 100'); } if (params.size < 1 || params.size > 1048576) { throw new Error('size must be between 1 and 1,048,576 bytes'); } if (params.format && !['base64', 'hex'].includes(params.format)) { throw new Error('format must be "base64" or "hex"'); } }