Skip to main content
Glama
gagarinyury

MCP Bitget Trading Server

by gagarinyury

getPositions

Retrieve current futures positions on Bitget exchange to monitor open trades, track exposure, and manage risk with optional symbol filtering.

Instructions

Get current futures positions

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolNoFilter by symbol

Implementation Reference

  • Core handler function that executes the logic to fetch current futures positions from Bitget API via REST endpoint '/api/v2/mix/position/all-position' and maps response to Position objects
    async getFuturesPositions(symbol?: string): Promise<Position[]> { 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/position/all-position', params, true); const positions = response.data || []; return positions.map((position: any) => ({ symbol: position.symbol, side: position.holdSide || (parseFloat(position.size || '0') > 0 ? 'long' : 'short'), size: Math.abs(parseFloat(position.size || position.total || '0')).toString(), entryPrice: position.averageOpenPrice || position.openPriceAvg, markPrice: position.markPrice, pnl: position.unrealizedPL || position.achievedProfits, pnlPercent: position.unrealizedPLR || '0', margin: position.margin || position.marginSize, leverage: position.leverage, timestamp: parseInt(position.cTime || Date.now().toString()) })); }
  • MCP server tool call handler for 'getPositions' that validates input and delegates to BitgetRestClient.getFuturesPositions
    case 'getPositions': { const { symbol } = GetPositionsSchema.parse(args); const positions = await this.bitgetClient.getFuturesPositions(symbol); return { content: [ { type: 'text', text: JSON.stringify(positions, null, 2), }, ], } as CallToolResult; }
  • src/server.ts:205-215 (registration)
    Registration of the 'getPositions' tool in the ListTools response, defining name, description, and input schema
    { name: 'getPositions', description: 'Get current futures positions', inputSchema: { type: 'object', properties: { symbol: { type: 'string', description: 'Filter by symbol' } }, required: [] }, },
  • Zod schema defining input validation for getPositions tool parameters
    export const GetPositionsSchema = z.object({ symbol: z.string().optional().describe('Filter by symbol') });

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