check_balance
Verify the SOL token balance of a connected wallet within Crossmint HR Airdrop MCP, designed for corporate HR teams managing token distributions to employees.
Instructions
Check the SOL balance of the connected wallet
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"properties": {},
"type": "object"
}
Implementation Reference
- src/server.ts:505-538 (handler)The handler function that executes the check_balance tool. It verifies a wallet is connected, retrieves the cached SOL balance, estimates required SOL for airdrop based on employee count, and returns a formatted status message.private async handleCheckBalance() { if (!this.state.connectedWallet) { throw new McpError( ErrorCode.InvalidRequest, 'No wallet connected. Please connect a wallet first.' ); } // In a real implementation, we would refresh the balance from the blockchain // For this demo, we'll just return the cached balance const { publicKey, solBalance } = this.state.connectedWallet; // Calculate required SOL for employees const employeeCount = this.state.employees.length || 1; // Default to 1 if no employees yet const requiredSol = 0.1 * employeeCount; // 0.1 SOL per employee const isSufficient = solBalance >= requiredSol; return { content: [ { type: 'text', text: ` Wallet Public Key: ${publicKey} Current SOL Balance: ${solBalance.toFixed(5)} SOL Required for Airdrop: ~${requiredSol.toFixed(5)} SOL (0.1 SOL per employee) Status: ${isSufficient ? 'Sufficient balance' : 'Insufficient balance'} ${!isSufficient ? 'Insufficient tokens. Create a new token? (yes/no)' : ''} `.trim(), }, ], }; }
- src/server.ts:154-157 (schema)The input schema for the check_balance tool, defined as an empty object since no parameters are required.inputSchema: { type: 'object', properties: {}, },
- src/server.ts:152-158 (registration)Registration of the check_balance tool in the ListToolsRequestSchema handler, including name, description, and schema.name: 'check_balance', description: 'Check the SOL balance of the connected wallet', inputSchema: { type: 'object', properties: {}, }, },
- src/server.ts:318-319 (registration)Dispatch case in the CallToolRequestSchema handler that routes check_balance calls to the handleCheckBalance method.case 'check_balance': return await this.handleCheckBalance();