generate_uuid
Create cryptographically secure UUIDs (v4) with customizable count and format options, ensuring reliable unique identifiers for various applications.
Instructions
Generate a cryptographically secure UUID (v4)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| count | No | Number of UUIDs to generate | |
| format | No | UUID format | standard |
Implementation Reference
- src/index.ts:468-495 (handler)Implements the generate_uuid tool logic using crypto.randomUUID() to generate UUID v4 strings, supports multiple UUIDs and standard/compact formats.private async generateUUID(args: any) { const count = args.count ?? 1; const format = args.format ?? "standard"; if (count < 1 || count > 100) { throw new Error("Count must be between 1 and 100"); } const results: string[] = []; for (let i = 0; i < count; i++) { const uuid = randomUUID(); results.push(format === "compact" ? uuid.replace(/-/g, "") : uuid); } return { content: [ { type: "text", text: JSON.stringify({ type: "uuids", values: results, parameters: { count, format }, timestamp: new Date().toISOString(), }, null, 2), }, ], }; }
- src/index.ts:136-154 (schema)Defines the input schema for the generate_uuid tool, including optional count (1-100) and format (standard/compact) parameters.inputSchema: { type: "object", properties: { count: { type: "integer", description: "Number of UUIDs to generate", default: 1, minimum: 1, maximum: 100, }, format: { type: "string", description: "UUID format", enum: ["standard", "compact"], default: "standard", }, }, required: [], },
- src/index.ts:133-155 (registration)Registers the generate_uuid tool in the ListToolsRequestSchema handler with name, description, and input schema.{ name: "generate_uuid", description: "Generate a cryptographically secure UUID (v4)", inputSchema: { type: "object", properties: { count: { type: "integer", description: "Number of UUIDs to generate", default: 1, minimum: 1, maximum: 100, }, format: { type: "string", description: "UUID format", enum: ["standard", "compact"], default: "standard", }, }, required: [], }, },
- src/index.ts:255-256 (registration)Registers the tool dispatch in the CallToolRequestSchema switch statement, routing generate_uuid calls to the generateUUID handler.case "generate_uuid": return await this.generateUUID(args);