Skip to main content
Glama

transfer

Send SOL tokens securely from one wallet to another using your secret key, destination address, and specified amount on the Solana MCP Server.

Instructions

Transfer SOL from your keypair to another address

Input Schema

NameRequiredDescriptionDefault
amountYesAmount of SOL to send
secretKeyYesYour keypair's secret key (as comma-separated numbers or JSON array)
toAddressYesDestination wallet address

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "amount": { "description": "Amount of SOL to send", "exclusiveMinimum": 0, "type": "number" }, "secretKey": { "description": "Your keypair's secret key (as comma-separated numbers or JSON array)", "type": "string" }, "toAddress": { "description": "Destination wallet address", "type": "string" } }, "required": [ "secretKey", "toAddress", "amount" ], "type": "object" }

Implementation Reference

  • The handler function that implements the transfer logic: parses secretKey to Keypair, creates SystemProgram.transfer instruction, sends and confirms the transaction, returns success with signature or error.
    async ({ secretKey, toAddress, amount }) => { try { // Parse the secret key and create keypair let fromKeypair: Keypair; try { // First try parsing as comma-separated string const decoded = Uint8Array.from(secretKey.split(',').map(num => parseInt(num.trim()))); fromKeypair = Keypair.fromSecretKey(decoded); } catch { // If that fails, try as a JSON array string fromKeypair = Keypair.fromSecretKey(Uint8Array.from(JSON.parse(secretKey))); } // Convert SOL amount to lamports const lamports = amount * LAMPORTS_PER_SOL; // Create transfer instruction const transaction = new Transaction().add( SystemProgram.transfer({ fromPubkey: fromKeypair.publicKey, toPubkey: new PublicKey(toAddress), lamports, }) ); // Send and confirm transaction const signature = await sendAndConfirmTransaction( connection, transaction, [fromKeypair] ); return { content: [ { type: "text", text: `Transfer successful! From: ${fromKeypair.publicKey.toBase58()} To: ${toAddress} Amount: ${amount} SOL Transaction signature: ${signature} Explorer URL: https://explorer.solana.com/tx/${signature}`, }, ], }; } catch (err) { const error = err as Error; return { content: [ { type: "text", text: `Failed to transfer SOL: ${error.message}`, }, ], }; } }
  • Zod schema for 'transfer' tool inputs: secretKey (string), toAddress (string), amount (positive number).
    { secretKey: z.string().describe("Your keypair's secret key (as comma-separated numbers or JSON array)"), toAddress: z.string().describe("Destination wallet address"), amount: z.number().positive().describe("Amount of SOL to send"), },
  • src/index.ts:207-272 (registration)
    Registration of the 'transfer' tool via server.tool() call, including name, description, input schema, and handler reference.
    server.tool( "transfer", "Transfer SOL from your keypair to another address", { secretKey: z.string().describe("Your keypair's secret key (as comma-separated numbers or JSON array)"), toAddress: z.string().describe("Destination wallet address"), amount: z.number().positive().describe("Amount of SOL to send"), }, async ({ secretKey, toAddress, amount }) => { try { // Parse the secret key and create keypair let fromKeypair: Keypair; try { // First try parsing as comma-separated string const decoded = Uint8Array.from(secretKey.split(',').map(num => parseInt(num.trim()))); fromKeypair = Keypair.fromSecretKey(decoded); } catch { // If that fails, try as a JSON array string fromKeypair = Keypair.fromSecretKey(Uint8Array.from(JSON.parse(secretKey))); } // Convert SOL amount to lamports const lamports = amount * LAMPORTS_PER_SOL; // Create transfer instruction const transaction = new Transaction().add( SystemProgram.transfer({ fromPubkey: fromKeypair.publicKey, toPubkey: new PublicKey(toAddress), lamports, }) ); // Send and confirm transaction const signature = await sendAndConfirmTransaction( connection, transaction, [fromKeypair] ); return { content: [ { type: "text", text: `Transfer successful! From: ${fromKeypair.publicKey.toBase58()} To: ${toAddress} Amount: ${amount} SOL Transaction signature: ${signature} Explorer URL: https://explorer.solana.com/tx/${signature}`, }, ], }; } catch (err) { const error = err as Error; return { content: [ { type: "text", text: `Failed to transfer SOL: ${error.message}`, }, ], }; } } );

Other Tools

Related Tools

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

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