UNPKG

mcp-rand

Version:

MCP server providing random generation utilities including UUID, numbers, strings, passwords, Gaussian distribution, dice rolling, and card drawing

37 lines 1.22 kB
import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js'; export const toolSpec = { name: 'generate_random_number', description: 'Generate a random number within a specified range', inputSchema: { type: 'object', properties: { min: { type: 'number', description: 'Minimum value (inclusive). Defaults to 0.', }, max: { type: 'number', description: 'Maximum value (inclusive). Defaults to 100.', }, }, } }; export const generateRandomNumberHandler = async (request) => { const args = request.params.arguments; const min = args.min ?? 0; const max = args.max ?? 100; if (min > max) { throw new McpError(ErrorCode.InvalidParams, 'Min value cannot be greater than max value'); } // Generate random number between min and max (inclusive) const randomNumber = Math.floor(Math.random() * (max - min + 1)) + min; return { content: [ { type: 'text', text: randomNumber.toString() } ] }; }; //# sourceMappingURL=generate-random-number.handler.js.map