getMarginInfo
Retrieve margin account details for cryptocurrency trading on Bitget, including balances and positions, to monitor risk exposure and manage leveraged positions effectively.
Instructions
Get margin account information
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | No | Filter by symbol |
Implementation Reference
- src/server.ts:455-466 (handler)MCP tool handler: parses arguments using GetMarginInfoSchema, calls BitgetRestClient.getMarginInfo(symbol), and returns JSON stringified result.
case 'getMarginInfo': { const { symbol } = GetMarginInfoSchema.parse(args); const marginInfo = await this.bitgetClient.getMarginInfo(symbol); return { content: [ { type: 'text', text: JSON.stringify(marginInfo, null, 2), }, ], } as CallToolResult; } - src/types/mcp.ts:93-95 (schema)Zod input schema for getMarginInfo tool: optional symbol parameter.
export const GetMarginInfoSchema = z.object({ symbol: z.string().optional().describe('Filter by symbol') }); - src/server.ts:228-238 (registration)Tool registration in MCP server's listTools handler: defines name, description, and JSON input schema.
{ name: 'getMarginInfo', description: 'Get margin account information', inputSchema: { type: 'object', properties: { symbol: { type: 'string', description: 'Filter by symbol' } }, required: [] }, }, - src/api/rest-client.ts:802-811 (helper)BitgetRestClient helper method: fetches margin account details from Bitget API endpoint /api/v2/mix/account/accounts for USDT-FUTURES.
async getMarginInfo(symbol?: string): Promise<any> { const params: any = { productType: 'USDT-FUTURES' }; if (symbol) { // Add _UMCBL suffix for futures if not present params.symbol = symbol.includes('_') ? symbol : `${symbol}_UMCBL`; } const response = await this.request<any>('GET', '/api/v2/mix/account/accounts', params, true); return response.data; }