Skip to main content
Glama

import_wallet

Import an existing Solana wallet using a private key or mnemonic phrase to manage assets and interact with the blockchain.

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 handler function for the 'import_wallet' tool. It extracts name and privateKey from arguments, checks if wallet name exists, decodes the base58-encoded private key to create a Keypair, stores the wallet in the global wallets map, and returns the wallet details on success or throws an error on failure.
    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 input schema definition for the 'import_wallet' tool, specifying required parameters: name (string) and privateKey (base58 string). Part of the tools array used for tool listing.
    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-1290 (registration)
    The switch case in the main CallToolRequestSchema handler that registers and dispatches calls to the 'import_wallet' handler function.
    case "import_wallet": result = await handleImportWallet(args); break;

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