Skip to main content
Glama

import_wallet

Import an existing Solana wallet using a private key or mnemonic to manage assets and perform blockchain operations.

Instructions

Import an existing wallet from private key or mnemonic

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesName for the wallet
privateKeyYesPrivate key in base58 format

Implementation Reference

  • The main handler function that imports a wallet by decoding the base58-encoded private key, creating a Keypair, storing it in the wallets map, and returning the wallet name and address.
    async function handleImportWallet(args: any) { const { name, privateKey } = args; if (wallets.has(name)) { throw new Error(`Wallet with name '${name}' already exists`); } try { const secretKey = bs58.decode(privateKey); const keypair = Keypair.fromSecretKey(secretKey); wallets.set(name, { keypair, name }); return { success: true, wallet: { name, address: keypair.publicKey.toString() } }; } catch (error) { throw new Error(`Invalid private key: ${error}`); } }
  • The tool definition in the tools array, including the name, description, and inputSchema specifying required 'name' and 'privateKey' fields.
    { name: "import_wallet", description: "Import an existing wallet from private key or mnemonic", inputSchema: { type: "object", properties: { name: { type: "string", description: "Name for the wallet" }, privateKey: { type: "string", description: "Private key in base58 format" } }, required: ["name", "privateKey"] } },
  • src/index.ts:1288-1289 (registration)
    The switch case in the CallToolRequestSchema handler that registers and dispatches 'import_wallet' calls to the handleImportWallet function.
    case "import_wallet": result = await handleImportWallet(args);

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/ExpertVagabond/solana-mcp-server'

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