Skip to main content
Glama
Jake-loranger

Algorand MCP Server

load_wallet

Access a stored Algorand wallet by providing its name and password to retrieve the associated blockchain address for transactions.

Instructions

Load a stored wallet and return the address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesWallet name/identifier
passwordYesPassword to decrypt the mnemonic

Implementation Reference

  • Main handler for the 'load_wallet' tool. Parses arguments, retrieves the stored wallet from in-memory storage, decrypts the mnemonic using AlgorandService, and returns the wallet address and decrypted mnemonic.
    case 'load_wallet': {
        const parsed = LoadWalletArgsSchema.parse(args);
        try {
            const wallet = walletStorage.get(parsed.name);
            if (!wallet) {
                throw new Error(`Wallet "${parsed.name}" not found`);
            }
    
            // Decrypt mnemonic
            const mnemonic = algorandService.decryptMnemonic(
                wallet.encryptedMnemonic,
                wallet.iv,
                parsed.password
            );
    
            return {
                content: [
                    {
                        type: 'text',
                        text: `Wallet "${parsed.name}" loaded successfully!\nAddress: ${wallet.address}\nMnemonic: ${mnemonic}\n\n⚠️ Keep this mnemonic secure and private.`,
                    },
                ],
            };
        } catch (error) {
            return {
                content: [
                    {
                        type: 'text',
                        text: `Error loading wallet: ${error}`,
                    },
                ],
                isError: true,
            };
        }
    }
  • Zod schema defining the input parameters for the load_wallet tool: wallet name and password.
    const LoadWalletArgsSchema = z.object({
        name: z.string(),
        password: z.string(),
    });
  • src/index.ts:345-362 (registration)
    Registration of the 'load_wallet' tool in the TOOLS array, including name, description, and input schema definition.
    {
        name: 'load_wallet',
        description: 'Load a stored wallet and return the address',
        inputSchema: {
            type: 'object',
            properties: {
                name: {
                    type: 'string',
                    description: 'Wallet name/identifier',
                },
                password: {
                    type: 'string',
                    description: 'Password to decrypt the mnemonic',
                },
            },
            required: ['name', 'password'],
        },
    },
  • Helper method in AlgorandService used by the load_wallet handler to decrypt the stored mnemonic phrase using AES-256-GCM.
    /**
     * Decrypt a mnemonic phrase
     */
    decryptMnemonic(encryptedData: string, iv: string, password: string): string {
        const key = crypto.scryptSync(password, 'salt', 32);
        const [encrypted, authTag] = encryptedData.split(':');
    
        if (!encrypted || !authTag) {
            throw new Error('Invalid encrypted data format');
        }
    
        const decipher = crypto.createDecipheriv('aes-256-gcm', key, Buffer.from(iv, 'hex'));
        decipher.setAuthTag(Buffer.from(authTag, 'hex'));
    
        let decrypted = decipher.update(encrypted, 'hex', 'utf8');
        decrypted += decipher.final('utf8');
    
        return decrypted;
    }

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