Skip to main content
Glama
Jake-loranger

Algorand MCP Server

store_wallet

Securely store an Algorand wallet by encrypting its mnemonic phrase with a password for protected access to blockchain accounts and transactions.

Instructions

Securely store a wallet with encrypted mnemonic

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesWallet name/identifier
mnemonicYesMnemonic phrase to store securely
passwordYesPassword to encrypt the mnemonic

Implementation Reference

  • Main handler function executing the store_wallet tool: validates input, imports account for address, encrypts mnemonic, stores in walletStorage Map.
    case 'store_wallet': {
        const parsed = StoreWalletArgsSchema.parse(args);
        try {
            // Import account to get address
            const account = algorandService.importAccountFromMnemonic(parsed.mnemonic);
    
            // Encrypt mnemonic
            const { encryptedMnemonic, iv } = algorandService.encryptMnemonic(parsed.mnemonic, parsed.password);
    
            // Store wallet
            walletStorage.set(parsed.name, {
                encryptedMnemonic,
                iv,
                address: account.addr.toString()
            });
    
            return {
                content: [
                    {
                        type: 'text',
                        text: `Wallet "${parsed.name}" stored securely!\nAddress: ${account.addr}\n\n⚠️ Remember your password - it's required to access the wallet.`,
                    },
                ],
            };
        } catch (error) {
            return {
                content: [
                    {
                        type: 'text',
                        text: `Error storing wallet: ${error}`,
                    },
                ],
                isError: true,
            };
        }
    }
  • Zod schema for validating store_wallet tool input arguments: name, mnemonic, password.
    const StoreWalletArgsSchema = z.object({
        name: z.string(),
        mnemonic: z.string(),
        password: z.string(),
    });
  • src/index.ts:323-344 (registration)
    Tool registration in the TOOLS array, defining name, description, and input schema for MCP server.
    {
        name: 'store_wallet',
        description: 'Securely store a wallet with encrypted mnemonic',
        inputSchema: {
            type: 'object',
            properties: {
                name: {
                    type: 'string',
                    description: 'Wallet name/identifier',
                },
                mnemonic: {
                    type: 'string',
                    description: 'Mnemonic phrase to store securely',
                },
                password: {
                    type: 'string',
                    description: 'Password to encrypt the mnemonic',
                },
            },
            required: ['name', 'mnemonic', 'password'],
        },
    },
  • Helper method in AlgorandService for encrypting mnemonic using AES-256-GCM with password-derived key.
    encryptMnemonic(mnemonic: string, password: string): { encryptedMnemonic: string; iv: string } {
        const key = crypto.scryptSync(password, 'salt', 32);
        const iv = crypto.randomBytes(16);
        const cipher = crypto.createCipheriv('aes-256-gcm', key, iv);
    
        let encrypted = cipher.update(mnemonic, 'utf8', 'hex');
        encrypted += cipher.final('hex');
    
        const authTag = cipher.getAuthTag();
    
        return {
            encryptedMnemonic: encrypted + ':' + authTag.toString('hex'),
            iv: iv.toString('hex')
        };
    }
  • Helper method to derive Algorand account (including address) from mnemonic phrase.
    importAccountFromMnemonic(mnemonic: string): algosdk.Account {
        return algosdk.mnemonicToSecretKey(mnemonic);
    }

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/Jake-loranger/algorand-mcp-server'

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