Skip to main content
Glama

mint_tokens

Mint tokens to a specified Solana wallet address using a designated token mint and authorized wallet.

Instructions

Mint tokens to a specific account

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
walletNameYesName of the wallet with mint authority
tokenMintYesToken mint address
destinationAddressYesDestination wallet address
amountYesAmount of tokens to mint (in token units, not raw)

Implementation Reference

  • The handler function that implements the mint_tokens tool logic. It retrieves the wallet, ensures connection, calculates raw amount based on decimals, creates destination token account if needed, and calls mintTo to mint tokens.
    async function handleMintTokens(args: any) { const { walletName, tokenMint, destinationAddress, amount } = args; const wallet = wallets.get(walletName); if (!wallet) { throw new Error(`Wallet '${walletName}' not found`); } ensureConnection(); const tokenMintPubkey = new PublicKey(tokenMint); const destinationPubkey = new PublicKey(destinationAddress); const mintInfo = await getMint(connection, tokenMintPubkey); const rawAmount = BigInt(Math.floor(amount * Math.pow(10, mintInfo.decimals))); const destinationTokenAccount = await getAssociatedTokenAddress( tokenMintPubkey, destinationPubkey ); // Check if destination token account exists, create if not try { await getAccount(connection, destinationTokenAccount); } catch { const transaction = new Transaction().add( createAssociatedTokenAccountInstruction( wallet.keypair.publicKey, destinationTokenAccount, destinationPubkey, tokenMintPubkey ) ); const { blockhash } = await connection.getLatestBlockhash(); transaction.recentBlockhash = blockhash; transaction.feePayer = wallet.keypair.publicKey; transaction.sign(wallet.keypair); await connection.sendTransaction(transaction, [wallet.keypair]); await new Promise(resolve => setTimeout(resolve, 2000)); // Wait for account creation } const signature = await mintTo( connection, wallet.keypair, tokenMintPubkey, destinationTokenAccount, wallet.keypair, rawAmount ); return { success: true, signature, amount, tokenMint: tokenMint, destination: destinationAddress, explorerUrl: `https://explorer.solana.com/tx/${signature}?cluster=${currentNetwork}` }; }
  • src/index.ts:325-350 (registration)
    Tool registration in the tools array, defining the name, description, and input schema for the mint_tokens tool.
    { name: "mint_tokens", description: "Mint tokens to a specific account", inputSchema: { type: "object", properties: { walletName: { type: "string", description: "Name of the wallet with mint authority" }, tokenMint: { type: "string", description: "Token mint address" }, destinationAddress: { type: "string", description: "Destination wallet address" }, amount: { type: "number", description: "Amount of tokens to mint (in token units, not raw)" } }, required: ["walletName", "tokenMint", "destinationAddress", "amount"] } },
  • src/index.ts:1333-1334 (registration)
    Dispatch case in the main CallToolRequestSchema handler that routes mint_tokens calls to the handleMintTokens function.
    case "mint_tokens": result = await handleMintTokens(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