Skip to main content
Glama

create_token_account

Create an associated token account for SPL tokens by specifying a wallet name and token mint address. This enables secure token management and transactions on the Solana blockchain.

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 creates an associated token account (ATA) for the specified wallet and token mint by constructing and signing a transaction using createAssociatedTokenAccountInstruction from @solana/spl-token.
    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:271-288 (registration)
    Tool definition and registration in the tools array used by the ListToolsRequestSchema handler, including name, description, and input schema.
    { 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"] } },
  • src/index.ts:1324-1326 (registration)
    Dispatch case in the switch statement of the CallToolRequestSchema handler that routes calls to the create_token_account handler 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