generate_random_string
Generate random alphanumeric strings of specified length for testing, security tokens, or unique identifiers.
Instructions
Generate a random string of specified length using alphanumeric characters
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| length | Yes | Length of the string to generate |
Implementation Reference
- src/index.ts:80-102 (handler)The handler implementation for generate_random_string, which validates the input length and generates a random alphanumeric string.
case "generate_random_string": { const { length } = args as { length: number }; if (length < 1) { throw new Error("String length must be at least 1"); } const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; let result = ""; for (let i = 0; i < length; i++) { result += characters.charAt(Math.floor(Math.random() * characters.length)); } return { content: [ { type: "text", text: `Generated random string: ${result}`, }, ], }; } - src/index.ts:37-51 (schema)The registration and schema definition for the generate_random_string tool.
{ name: "generate_random_string", description: "Generate a random string of specified length using alphanumeric characters", inputSchema: { type: "object", properties: { length: { type: "number", description: "Length of the string to generate", minimum: 1, }, }, required: ["length"], }, },