Check Balance
check_balanceCheck the SOL balance of any Solana wallet address. Get balance in SOL, ready-to-stake status, and next steps for staking.
Instructions
Check the SOL balance of any Solana wallet address. Returns balance in SOL, ready-to-stake status, and next steps.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| walletAddress | Yes | Solana wallet address (base58 public key) |
Implementation Reference
- server.ts:151-152 (registration)Registration of the 'check_balance' MCP tool using the McpServer SDK, including its title, description, input schema (zod-validated walletAddress string), and the async handler function.
mcp.registerTool('check_balance', { title: 'Check Balance', description: 'Check the SOL balance of any Solana wallet address. Returns balance in SOL, ready-to-stake status, and next steps.', inputSchema: { walletAddress: z.string().max(50).describe('Solana wallet address (base58 public key)') }, annotations: READ_ONLY }, async ({ walletAddress }) => { const { ok, data } = await api('GET', `/api/v1/wallet/balance/${walletAddress}`); if (!ok) return error(`Failed to check balance`, { retry: 'check_balance', generateWallet: 'generate_wallet' }); return result(data, { relatedTools: { stake: 'stake', stakeAccounts: 'check_stake_accounts' } }); }); - server.ts:152-152 (handler)Handler function for check_balance. Takes walletAddress, makes a GET call to /api/v1/wallet/balance/{walletAddress}, returns balance data or an error with related tool suggestions.
async ({ walletAddress }) => { const { ok, data } = await api('GET', `/api/v1/wallet/balance/${walletAddress}`); if (!ok) return error(`Failed to check balance`, { retry: 'check_balance', generateWallet: 'generate_wallet' }); return result(data, { relatedTools: { stake: 'stake', stakeAccounts: 'check_stake_accounts' } }); }); - server.ts:151-151 (schema)Input schema for check_balance: a single required walletAddress parameter (string, max 50 chars) validated with Zod.
mcp.registerTool('check_balance', { title: 'Check Balance', description: 'Check the SOL balance of any Solana wallet address. Returns balance in SOL, ready-to-stake status, and next steps.', inputSchema: { walletAddress: z.string().max(50).describe('Solana wallet address (base58 public key)') }, annotations: READ_ONLY }, - server.ts:15-30 (helper)Helper function 'api' used by the handler to make HTTP requests to the Blueprint API backend.
async function api( method: 'GET' | 'POST' | 'DELETE', path: string, body?: Record<string, unknown> ): Promise<{ ok: boolean; status: number; data: unknown }> { const url = `${API_BASE}${path}`; const headers: Record<string, string> = { 'Content-Type': 'application/json' }; const res = await fetch(url, { method, headers, signal: AbortSignal.timeout(30_000), ...(body ? { body: JSON.stringify(body) } : {}), }); const data = await res.json().catch(() => ({ error: 'non_json_response', status: res.status })); return { ok: res.ok, status: res.status, data }; }