Skip to main content
Glama

approve_delegate

Authorize a delegate to transfer specific tokens from your Solana wallet by setting transfer limits and permissions.

Instructions

Approve a delegate to transfer tokens on your behalf

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
walletNameYesName of the wallet that owns the tokens
tokenMintYesToken mint address
delegateAddressYesAddress of the delegate
amountYesMaximum amount delegate can transfer

Implementation Reference

  • The handler function that implements the approve_delegate tool logic. It approves a delegate for a specified token account using the SPL Token program's approve instruction, after validating the wallet, calculating the raw amount based on token decimals, and deriving the associated token account.
    async function handleApproveDelegate(args: any) { const { walletName, tokenMint, delegateAddress, amount } = args; const wallet = wallets.get(walletName); if (!wallet) { throw new Error(`Wallet '${walletName}' not found`); } ensureConnection(); const tokenMintPubkey = new PublicKey(tokenMint); const delegatePubkey = new PublicKey(delegateAddress); const mintInfo = await getMint(connection, tokenMintPubkey); const rawAmount = BigInt(Math.floor(amount * Math.pow(10, mintInfo.decimals))); const tokenAccount = await getAssociatedTokenAddress( tokenMintPubkey, wallet.keypair.publicKey ); const signature = await approve( connection, wallet.keypair, tokenAccount, delegatePubkey, wallet.keypair, rawAmount ); return { success: true, signature, delegate: delegateAddress, amount, explorerUrl: `https://explorer.solana.com/tx/${signature}?cluster=${currentNetwork}` }; }
  • The input schema definition for the approve_delegate tool, specifying parameters and validation rules, registered in the MCP tools list.
    { name: "approve_delegate", description: "Approve a delegate to transfer tokens on your behalf", inputSchema: { type: "object", properties: { walletName: { type: "string", description: "Name of the wallet that owns the tokens" }, tokenMint: { type: "string", description: "Token mint address" }, delegateAddress: { type: "string", description: "Address of the delegate" }, amount: { type: "number", description: "Maximum amount delegate can transfer" } }, required: ["walletName", "tokenMint", "delegateAddress", "amount"] } },
  • src/index.ts:1354-1356 (registration)
    Registration in the switch statement that dispatches calls to the handleApproveDelegate function in the main CallToolRequest handler.
    case "approve_delegate": result = await handleApproveDelegate(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