Skip to main content
Glama

Rootstock MCP Server

by cuongpo

import_wallet

Import an existing wallet into the Rootstock MCP Server using a private key or mnemonic phrase, with an optional name for wallet management.

Instructions

Import an existing wallet using private key or mnemonic phrase

Input Schema

NameRequiredDescriptionDefault
mnemonicNoMnemonic phrase to import (alternative to private key)
nameNoOptional name for the wallet
privateKeyNoPrivate key to import (alternative to mnemonic)

Input Schema (JSON Schema)

{ "properties": { "mnemonic": { "description": "Mnemonic phrase to import (alternative to private key)", "type": "string" }, "name": { "description": "Optional name for the wallet", "type": "string" }, "privateKey": { "description": "Private key to import (alternative to mnemonic)", "type": "string" } }, "type": "object" }

Implementation Reference

  • MCP tool handler for 'import_wallet': delegates to WalletManager.importWallet and returns formatted success response with wallet address.
    private async handleImportWallet(params: ImportWalletParams) { const walletInfo = this.walletManager.importWallet( params.privateKey, params.mnemonic, params.name ); return { content: [ { type: 'text', text: `Wallet imported successfully!\n\nAddress: ${walletInfo.address}`, }, ], }; }
  • src/index.ts:178-198 (registration)
    Registers the 'import_wallet' tool in the MCP server's tool list with description and JSON schema for inputs.
    { name: 'import_wallet', description: 'Import an existing wallet using private key or mnemonic phrase', inputSchema: { type: 'object', properties: { privateKey: { type: 'string', description: 'Private key to import (alternative to mnemonic)', }, mnemonic: { type: 'string', description: 'Mnemonic phrase to import (alternative to private key)', }, name: { type: 'string', description: 'Optional name for the wallet', }, }, }, },
  • TypeScript interface defining input parameters for import_wallet tool (privateKey, mnemonic, name).
    export interface ImportWalletParams { privateKey?: string; mnemonic?: string; name?: string; }
  • Core wallet import logic: creates ethers.Wallet from privateKey or validated mnemonic, stores in manager, sets as current if first.
    importWallet(privateKey?: string, mnemonic?: string, _name?: string): WalletInfo { try { let wallet: ethers.Wallet | ethers.HDNodeWallet; if (privateKey) { wallet = new ethers.Wallet(privateKey); } else if (mnemonic) { if (!bip39.validateMnemonic(mnemonic)) { throw new Error('Invalid mnemonic phrase'); } wallet = ethers.Wallet.fromPhrase(mnemonic); } else { throw new Error('Either private key or mnemonic must be provided'); } // Store the wallet this.wallets.set(wallet.address.toLowerCase(), wallet); // Set as current wallet if it's the first one if (!this.currentWallet) { this.currentWallet = wallet.address.toLowerCase(); } return { address: wallet.address, privateKey: wallet.privateKey, mnemonic, publicKey: 'publicKey' in wallet ? (wallet as any).publicKey : undefined, }; } catch (error) { throw new Error(`Failed to import wallet: ${error}`); } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cuongpo/rootstock-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server