Skip to main content
Glama

mint_tokens

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

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

  • Handler function that executes the mint_tokens tool. Validates wallet, ensures connection, calculates raw amount based on decimals, creates associated 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}` }; }
  • Tool schema definition including name, description, and inputSchema with required parameters for minting tokens.
    { 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-1335 (registration)
    Registration in the tool dispatch switch statement within the CallToolRequestSchema handler, mapping 'mint_tokens' to handleMintTokens.
    case "mint_tokens": result = await handleMintTokens(args); break;
  • src/index.ts:1273-1275 (registration)
    Registration of the tools list for ListToolsRequestSchema, which includes the mint_tokens tool.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { 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/ExpertVagabond/solana-mcp-server'

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