Skip to main content
Glama
gagarinyury

MCP Bitget Trading Server

by gagarinyury

getBalance

Retrieve account balance details on the Bitget cryptocurrency exchange. Query specific assets or view all balances in real-time for informed trading decisions.

Instructions

Get account balance information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
assetNoSpecific asset to query

Implementation Reference

  • MCP tool handler for 'getBalance' that validates input using GetBalanceSchema and delegates to BitgetRestClient.getBalance
    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; }
  • Zod input schema for the getBalance tool, defining optional 'asset' parameter
    export const GetBalanceSchema = z.object({ asset: z.string().optional().describe('Specific asset to query') });
  • src/server.ts:150-160 (registration)
    Tool registration in listTools handler, defining name, description, and JSON schema matching GetBalanceSchema
    { name: 'getBalance', description: 'Get account balance information', inputSchema: { type: 'object', properties: { asset: { type: 'string', description: 'Specific asset to query' } }, required: [] }, },
  • Implementation of getBalance in BitgetRestClient that fetches spot account assets via API and maps to Balance type, optionally filtering by asset
    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; }

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/gagarinyury/MCP-bitget-trading'

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