Skip to main content
Glama
monostate

Crossmint HR Airdrop MCP

by monostate

add_liquidity

Enhance liquidity pools by adding specified amounts of tokens and SOL. Supports HR teams in managing token airdrops for employees with automated processes.

Instructions

Add liquidity to the created token

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
solAmountYesAmount of SOL to add to liquidity pool
tokenAmountYesAmount of tokens to add to liquidity pool

Implementation Reference

  • src/server.ts:185-202 (registration)
    Registration of the 'add_liquidity' tool in the MCP server's tool list, including name, description, and input schema.
    {
      name: 'add_liquidity',
      description: 'Add liquidity to the created token',
      inputSchema: {
        type: 'object',
        properties: {
          tokenAmount: {
            type: 'number',
            description: 'Amount of tokens to add to liquidity pool',
          },
          solAmount: {
            type: 'number',
            description: 'Amount of SOL to add to liquidity pool',
          },
        },
        required: ['tokenAmount', 'solAmount'],
      },
    },
  • The primary handler for the 'add_liquidity' MCP tool. Validates arguments using Zod, checks connected wallet and created token prerequisites, simulates liquidity provision by deducting SOL from state balance, and returns formatted success response.
      private async handleAddLiquidity(args: any) {
        if (!this.state.connectedWallet) {
          throw new McpError(
            ErrorCode.InvalidRequest,
            'No wallet connected. Please connect a wallet first.'
          );
        }
    
        if (!this.state.createdToken) {
          throw new McpError(
            ErrorCode.InvalidRequest,
            'No token created. Please create a token first.'
          );
        }
    
        // Validate input
        const schema = z.object({
          tokenAmount: z.number().positive(),
          solAmount: z.number().positive(),
        });
        
        const { tokenAmount, solAmount } = schema.parse(args);
        
        // Check if we have enough balance
        if (this.state.connectedWallet.solBalance < solAmount) {
          throw new McpError(
            ErrorCode.InvalidRequest,
            `Insufficient SOL balance. You have ${this.state.connectedWallet.solBalance} SOL, but ${solAmount} SOL is required.`
          );
        }
        
        // In a real implementation, we would call the Raydium liquidity addition function
        // For this demo, we'll simulate liquidity addition
        
        // Update SOL balance
        this.state.connectedWallet.solBalance -= solAmount;
        
        return {
          content: [
            {
              type: 'text',
              text: `
    Liquidity added successfully:
    Token: ${this.state.createdToken.symbol}
    Token Amount: ${tokenAmount.toLocaleString()} ${this.state.createdToken.symbol}
    SOL Amount: ${solAmount} SOL
    Remaining SOL Balance: ${this.state.connectedWallet.solBalance} SOL
    
    Next step: Generate wallets for employees.
              `.trim(),
            },
          ],
        };
      }
  • Utility helper function to add liquidity for a token mint. Creates associated token account if needed and sends transaction (simplified simulation). Imported in server.ts and tokenUtils.ts but not called in the MCP handler.
    export async function addLiquidity(
      connection: Connection,
      payer: Keypair,
      mintAddress: string,
      tokenAmount: number,
      solAmount: number
    ): Promise<{ txId: string }> {
      try {
        console.log(`Adding liquidity: ${tokenAmount} tokens + ${solAmount} SOL`);
        
        // Convert mintAddress string to PublicKey
        const mintPublicKey = new PublicKey(mintAddress);
        
        // Create a transaction
        const transaction = new Transaction();
        
        // Get the associated token account for the payer
        const tokenAccount = await getAssociatedTokenAddress(
          mintPublicKey,
          payer.publicKey
        );
        
        // Check if the token account exists
        try {
          await getAccount(connection, tokenAccount);
        } catch (error) {
          // If the token account doesn't exist, create it
          transaction.add(
            createAssociatedTokenAccountInstruction(
              payer.publicKey,
              tokenAccount,
              payer.publicKey,
              mintPublicKey
            )
          );
        }
        
        // In a real implementation, this would interact with a DEX like Raydium
        // For now, we'll just simulate the liquidity addition by transferring tokens
        // to a "liquidity pool" (which is just the payer's account in this simulation)
        
        // Send the transaction
        const signature = await sendAndConfirmTransaction(
          connection,
          transaction,
          [payer]
        );
        
        console.log(`Liquidity added with transaction ID: ${signature}`);
        
        return {
          txId: signature
        };
      } catch (error: any) {
        console.error('Error adding liquidity:', error);
        throw new Error(`Liquidity addition failed: ${error.message}`);
      }
    }
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