Skip to main content
Glama

unstake_msol

Convert mSOL tokens back to SOL tokens through Marinade Finance's liquid staking protocol. Specify the amount to unstake.

Instructions

Unstake your mSOL tokens with Marinade Finance to receive SOL tokens.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
amountYesThe amount of mSOL to unstake

Implementation Reference

  • Handler function that executes the unstake_msol tool logic: converts amount to lamports, sets up Solana connection and wallet, initializes Marinade instance, calls liquidUnstake, sends and confirms the transaction, returns success details or handles errors.
    callback: async ({ amount }: { amount: number }) => { try { const amountLamports = MarinadeUtils.solToLamports(amount); const { wallet, connection } = createSolanaConfig() const config = new MarinadeConfig({ connection, publicKey: wallet.publicKey, }) const marinade = new Marinade(config) const { associatedMSolTokenAccountAddress, transaction, } = await marinade.liquidUnstake(amountLamports) const signature = await sendAndConfirmTransaction(connection, transaction, [wallet], { commitment: "confirmed", preflightCommitment: "processed", skipPreflight: false, maxRetries: 3, }) return { content: [ { type: "text", text: JSON.stringify({ success: true, signature, mSolTokenAccount: associatedMSolTokenAccountAddress, amountUnstaked: amount, amountUnstakedLamports: amountLamports.toString(), explorerUrl: `https://solscan.io/tx/${signature}${process.env.ENVIRONMENT === 'MAINNET' ? '' : '?cluster=devnet'}` }, null, 2), }, ], }; } catch (err) { const isAbort = (err as Error)?.name === "AbortError"; const isTimeout = (err as Error)?.message?.includes("timeout"); McpLogger.error("Error in stake_msol tool:", String(err)); return { content: [ { type: "text", text: JSON.stringify( { error: isAbort || isTimeout ? "Request timed out" : "Failed to stake SOL", reason: String((err as Error)?.message ?? err), suggestion: isAbort || isTimeout ? "The transaction may still be processing. Check your wallet or try again with a different RPC endpoint." : "Please check your wallet balance and network connection." }, null, 2 ), }, ], }; } }
  • Zod input schema for the unstake_msol tool, validating the amount parameter as a positive number.
    inputSchema: { amount: z.number().min(0).describe("The amount of mSOL to unstake"), },
  • src/server.ts:25-43 (registration)
    Registration loop that registers all tools from marinadeFinanceTools array, including unstake_msol, with the MCP server using name, title, description, inputSchema, and wrapping the callback.
    for (const t of marinadeFinanceTools) { server.registerTool( t.name, { title: t.title, description: t.description, inputSchema: t.inputSchema }, async (args) => { const result = await t.callback(args); return { content: result.content.map(item => ({ ...item, type: "text" as const })) }; } ); }

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/leandrogavidia/marinade-finance-mcp-server'

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