Skip to main content
Glama

create_token_account

Create an associated token account for SPL tokens on the Solana blockchain to enable token storage and transfers.

Instructions

Create associated token account for SPL tokens

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
walletNameYesName of the wallet
tokenMintYesToken mint address

Implementation Reference

  • The handler function that executes the create_token_account tool. It retrieves the wallet, computes the associated token account address, builds a transaction to create the ATA using createAssociatedTokenAccountInstruction, signs and sends it, returning the token account address and transaction signature.
    async function handleCreateTokenAccount(args: any) { const { walletName, tokenMint } = args; const wallet = wallets.get(walletName); if (!wallet) { throw new Error(`Wallet '${walletName}' not found`); } ensureConnection(); const tokenMintPubkey = new PublicKey(tokenMint); const tokenAccount = await getAssociatedTokenAddress(tokenMintPubkey, wallet.keypair.publicKey); const transaction = new Transaction().add( createAssociatedTokenAccountInstruction( wallet.keypair.publicKey, tokenAccount, wallet.keypair.publicKey, tokenMintPubkey ) ); const { blockhash } = await connection.getLatestBlockhash(); transaction.recentBlockhash = blockhash; transaction.feePayer = wallet.keypair.publicKey; transaction.sign(wallet.keypair); const signature = await connection.sendTransaction(transaction, [wallet.keypair]); return { success: true, tokenAccount: tokenAccount.toString(), signature, explorerUrl: `https://explorer.solana.com/tx/${signature}?cluster=${currentNetwork}` }; }
  • src/index.ts:272-288 (registration)
    The tool registration in the MCP tools array, defining the name, description, and input schema for validation.
    name: "create_token_account", description: "Create associated token account for SPL tokens", inputSchema: { type: "object", properties: { walletName: { type: "string", description: "Name of the wallet" }, tokenMint: { type: "string", description: "Token mint address" } }, required: ["walletName", "tokenMint"] } },
  • The input schema defining parameters for the create_token_account tool: walletName and tokenMint.
    inputSchema: { type: "object", properties: { walletName: { type: "string", description: "Name of the wallet" }, tokenMint: { type: "string", description: "Token mint address" } }, required: ["walletName", "tokenMint"] }
  • The dispatch case in the main CallToolRequestSchema handler that routes calls to the specific handleCreateTokenAccount function.
    case "create_token_account": result = await handleCreateTokenAccount(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