gen_mnemonic
Generate mnemonic phrases for Sui blockchain wallets. Designed for testing purposes and not recommended for production use, it creates secure phrases to manage wallet access.
Instructions
Generate mnemonic(Not recommended for production)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| num | No |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"num": {
"default": 1,
"type": "number"
}
},
"type": "object"
}
Implementation Reference
- src/tools/account/gen-mnemonic.ts:11-25 (handler)The GenMnemonicTool class implements the core logic for the 'gen_mnemonic' tool. It extends BaseTool, sets the name and description, defines the paramsSchema, and provides the 'cb' async handler function that generates the specified number of random mnemonics using genRandomMnemonic and returns them as a JSON string response.export class GenMnemonicTool extends BaseTool<MnemonicParams> { name = 'gen_mnemonic'; description = 'Generate mnemonic(Not recommended for production)'; paramsSchema = mnemonicParamsSchema; async cb(args: MnemonicParams) { const mnemonics = []; for (let i = 0; i < args.num; i++) { const mnemonic = genRandomMnemonic(); mnemonics.push(mnemonic); } return this.createTextResponse(JSON.stringify(mnemonics)); } }
- Zod schema and TypeScript type for the tool's input parameters: 'num' number defaulting to 1, indicating how many mnemonics to generate.const mnemonicParamsSchema = z.object({ num: z.number().default(1), }); type MnemonicParams = z.output<typeof mnemonicParamsSchema>;
- src/tools/index.ts:9-17 (registration)The genMnemonicTool instance is included in the default export array of all tools from src/tools/index.ts, serving as the central registration point for MCP tools.export default [ faucetTool, suiBalanceTool, suiTransferTool, randomSuiAccountTool, genMnemonicTool, genSuiAccountsByMnemonicTool, getAccountInfoByPriKeyTool, ];
- src/tools/account/gen-mnemonic.ts:27-27 (registration)Instantiation and default export of the GenMnemonicTool instance, which is imported and registered in src/tools/index.ts.export default new GenMnemonicTool();
- src/utils/keypair.ts:39-43 (helper)Supporting utility function genRandomMnemonic() that uses bip39.generateMnemonic() to produce a random mnemonic phrase, invoked in the tool's handler.export function genRandomMnemonic() { const mnemonic = bip39.generateMnemonic(); return mnemonic; }