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
| Name | Required | Description | Default |
|---|---|---|---|
| walletName | Yes | Name of the wallet | |
| tokenMint | Yes | Token mint address |
Implementation Reference
- src/index.ts:835-870 (handler)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"] } },
- src/index.ts:274-287 (schema)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"] }
- src/index.ts:1324-1326 (handler)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;