Skip to main content
Glama
monostate

Crossmint HR Airdrop MCP

by monostate

create_token

Generate a new Solana token by specifying name, symbol, supply, and decimals. Designed for HR teams using Crossmint HR Airdrop MCP to facilitate role-based token distribution and email notifications.

Instructions

Create a new Solana token

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
decimalsNoToken decimals (default: 9)
nameYesToken name
supplyYesTotal token supply
symbolYesToken symbol

Implementation Reference

  • src/server.ts:159-184 (registration)
    Registration of the 'create_token' MCP tool including its input schema definition.
    {
      name: 'create_token',
      description: 'Create a new Solana token',
      inputSchema: {
        type: 'object',
        properties: {
          name: {
            type: 'string',
            description: 'Token name',
          },
          symbol: {
            type: 'string',
            description: 'Token symbol',
          },
          supply: {
            type: 'number',
            description: 'Total token supply',
          },
          decimals: {
            type: 'number',
            description: 'Token decimals (default: 9)',
          },
        },
        required: ['name', 'symbol', 'supply'],
      },
    },
  • MCP tool handler for 'create_token' that validates parameters, calls the createToken utility, updates server state, and returns success response.
      private async handleCreateToken(args: any) {
        if (!this.state.connectedWallet) {
          throw new McpError(
            ErrorCode.InvalidRequest,
            'No wallet connected. Please connect a wallet first.'
          );
        }
    
        // Validate input
        const schema = z.object({
          name: z.string(),
          symbol: z.string(),
          supply: z.number().positive(),
          decimals: z.number().min(0).max(9).default(9),
        });
        
        const { name, symbol, supply, decimals } = schema.parse(args);
        
        try {
          // Create a dummy connection and keypair for simulation
          const connection = new Connection('https://api.mainnet-beta.solana.com', 'confirmed');
          const keypair = Keypair.generate(); // In a real implementation, this would be the user's wallet
          
          // Call the token creation utility
          const result = await createToken(
            connection,
            keypair,
            name,
            symbol,
            supply,
            decimals
          );
          
          if (!result.mintAddress) {
            throw new Error('Token creation failed: No mint address returned');
          }
          
          // Update state
          this.state.createdToken = {
            name,
            symbol,
            mintAddress: result.mintAddress,
            supply,
            decimals,
          };
        } catch (error) {
          throw new McpError(
            ErrorCode.InternalError,
            `Token creation failed: ${error instanceof Error ? error.message : String(error)}`
          );
        }
        
        return {
          content: [
            {
              type: 'text',
              text: `
    Token created successfully:
    Name: ${name}
    Symbol: ${symbol}
    Supply: ${supply.toLocaleString()}
    Decimals: ${decimals}
    Mint Address: ${this.state.createdToken?.mintAddress}
    
    Next step: Add liquidity to give the token value.
              `.trim(),
            },
          ],
        };
      }
  • Core implementation of token creation logic using SPL Token program; exported as createToken from tokenUtils.ts and called by the MCP handler.
    export async function deployToken(
      connection: Connection,
      payer: Keypair,
      name: string,
      symbol: string,
      supply: number,
      decimals: number = 9
    ): Promise<{ mintAddress: string }> {
      try {
        console.log(`Creating token: ${name} (${symbol}) with supply ${supply}`);
        
        // Check payer balance
        const balance = await connection.getBalance(payer.publicKey);
        console.log(`Payer balance: ${balance / LAMPORTS_PER_SOL} SOL`);
        
        if (balance < 0.05 * LAMPORTS_PER_SOL) {
          throw new Error(`Insufficient balance: ${balance / LAMPORTS_PER_SOL} SOL. Need at least 0.05 SOL.`);
        }
        
        // Generate a new keypair for the mint account
        const mintKeypair = Keypair.generate();
        console.log(`Mint keypair generated: ${mintKeypair.publicKey.toString()}`);
        
        // Get the minimum lamports required for the mint
        const lamports = await getMinimumBalanceForRentExemptMint(connection);
        
        // Create a transaction to create the mint account
        const transaction = new Transaction();
        
        // Add instruction to create the mint account
        transaction.add(
          SystemProgram.createAccount({
            fromPubkey: payer.publicKey,
            newAccountPubkey: mintKeypair.publicKey,
            space: MINT_SIZE,
            lamports,
            programId: TOKEN_PROGRAM_ID,
          })
        );
        
        // Add instruction to initialize the mint account
        transaction.add(
          createInitializeMintInstruction(
            mintKeypair.publicKey,
            decimals,
            payer.publicKey,
            payer.publicKey
          )
        );
        
        // If supply is greater than 0, mint tokens to the payer
        if (supply > 0) {
          // Get the associated token account for the payer
          const associatedTokenAccount = await getAssociatedTokenAddress(
            mintKeypair.publicKey,
            payer.publicKey
          );
          
          // Add instruction to create the associated token account if it doesn't exist
          transaction.add(
            createAssociatedTokenAccountInstruction(
              payer.publicKey,
              associatedTokenAccount,
              payer.publicKey,
              mintKeypair.publicKey
            )
          );
          
          // Add instruction to mint tokens to the payer's associated token account
          transaction.add(
            createMintToInstruction(
              mintKeypair.publicKey,
              associatedTokenAccount,
              payer.publicKey,
              supply * Math.pow(10, decimals)
            )
          );
        }
        
        // Send and confirm the transaction
        const signature = await sendAndConfirmTransaction(
          connection,
          transaction,
          [payer, mintKeypair]
        );
        
        console.log(`Transaction signature: ${signature}`);
        
        // Return the mint address
        const mint = mintKeypair.publicKey;
        
        console.log(`Token mint created: ${mint.toString()}`);
        
        return {
          mintAddress: mint.toString()
        };
      } catch (error: any) {
        console.error('Error deploying token:', error);
        throw new Error(`Token deployment failed: ${error.message}`);
      }
    }
  • Re-export of deployToken as createToken for use in server.ts.
    /**
     * Create a new token on Solana
     */
    export { deployToken as createToken };
Install Server

Other Tools

Related 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/monostate/Employees-Airdrop-Rewards-MCP'

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