wallet_create_mnemonic_phrase
Generate a secure mnemonic phrase for Ethereum and EVM-compatible wallets, with customizable length and optional locale support for enhanced usability.
Instructions
Create a mnemonic phrase
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| length | Yes | The length of the mnemonic phrase | |
| locale | No | Optional locale for the wordlist |
Implementation Reference
- src/handlers/wallet.ts:81-98 (handler)The main handler function that generates a mnemonic phrase of the specified length using the @scure/bip39 library. It dynamically imports the wordlist based on locale and calculates entropy bits from the word count.export const createMnemonicPhraseHandler = async (input: createMnemonicPhraseHandlerInput): Promise<ToolResultSchema> => { try { const { wordlist } = await import(`@scure/bip39/wordlists/${input.locale || 'english'}`); if (!wordlist) { return createErrorResponse("Invalid locale"); } // Convert length to entropy bits (12 words = 128 bits, 15 words = 160 bits, etc) const entropyBits = ((input.length ?? 12) / 3) * 32; const mnemonic = generateMnemonic(wordlist, entropyBits); return createSuccessResponse( `Mnemonic phrase created successfully: Mnemonic: "${mnemonic}" `); } catch (error) { return createErrorResponse(`Failed to create mnemonic phrase: ${(error as Error).message}`); } };
- src/tools.ts:76-87 (schema)The tool schema definition including name, description, and input schema specifying the length (12-24 words) and optional locale.{ name: "wallet_create_mnemonic_phrase", description: "Create a mnemonic phrase", inputSchema: { type: "object", properties: { length: { type: "number", description: "The length of the mnemonic phrase", enum: [12, 15, 18, 21, 24] }, locale: { type: "string", description: "Optional locale for the wordlist" } }, required: ["length"] } },
- src/tools.ts:607-607 (registration)Registration of the handler function in the tools handlers dictionary."wallet_create_mnemonic_phrase": createMnemonicPhraseHandler
- src/handlers/wallet.types.ts:6-9 (schema)TypeScript type definition for the handler input, matching the tool schema.export type createMnemonicPhraseHandlerInput = { locale?: string; length?: 12 | 15 | 18 | 21 | 24; };