generate_random_hex
Generate random hexadecimal strings for development needs like unique identifiers, cryptographic keys, or test data by specifying byte length.
Instructions
Generate a random hexadecimal string of the specified byte length.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bytes | No | Number of random bytes (output will be 2x this length in hex) |
Implementation Reference
- src/tools/generators.ts:137-140 (handler)Handler for generate_random_hex, using randomBytes to generate the hex string.
async ({ bytes }) => ({ content: [ { type: "text" as const, text: randomBytes(bytes).toString("hex") }, ], - src/tools/generators.ts:128-136 (schema)Zod schema defining the input for generate_random_hex.
{ bytes: z .number() .int() .min(1) .max(256) .default(16) .describe("Number of random bytes (output will be 2x this length in hex)"), }, - src/tools/generators.ts:125-136 (registration)Registration of the generate_random_hex tool on the MCP server.
server.tool( "generate_random_hex", "Generate a random hexadecimal string of the specified byte length.", { bytes: z .number() .int() .min(1) .max(256) .default(16) .describe("Number of random bytes (output will be 2x this length in hex)"), },