getBalance
Retrieve cryptocurrency account balance information from Bitget exchange to monitor available funds for trading decisions.
Instructions
Get account balance information
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "getBalance"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| asset | No | Specific asset to query |
Implementation Reference
- src/server.ts:367-378 (handler)MCP tool handler for 'getBalance': validates input using GetBalanceSchema, calls BitgetRestClient.getBalance(asset), returns JSON-formatted balance data.
case 'getBalance': { const { asset } = GetBalanceSchema.parse(args); const balance = await this.bitgetClient.getBalance(asset); return { content: [ { type: 'text', text: JSON.stringify(balance, null, 2), }, ], } as CallToolResult; } - src/types/mcp.ts:62-64 (schema)Zod schema definition for getBalance tool input parameters.
export const GetBalanceSchema = z.object({ asset: z.string().optional().describe('Specific asset to query') }); - src/server.ts:150-160 (registration)Tool registration in listTools response: defines name, description, and input schema for getBalance.
{ name: 'getBalance', description: 'Get account balance information', inputSchema: { type: 'object', properties: { asset: { type: 'string', description: 'Specific asset to query' } }, required: [] }, }, - src/api/rest-client.ts:519-534 (helper)BitgetRestClient.getBalance method: fetches spot account assets via API, formats into Balance[] array, filters by asset if specified.
async getBalance(asset?: string): Promise<Balance[]> { const response = await this.request<any>('GET', '/api/v2/spot/account/assets', {}, true); const balances = response.data.map((item: any) => ({ asset: item.coin, free: item.available, locked: item.frozen, total: (parseFloat(item.available) + parseFloat(item.frozen)).toString() })); if (asset) { return balances.filter((balance: Balance) => balance.asset === asset); } return balances; }