Skip to main content
Glama

MCP Bitget Trading Server

by gagarinyury

getPrice

Retrieve real-time spot or futures trading prices for specified cryptocurrency pairs using this tool, enabling accurate market data access for trading decisions.

Instructions

Get current price for a trading pair (spot or futures)

Input Schema

NameRequiredDescriptionDefault
symbolYesTrading pair symbol (e.g., BTCUSDT for spot, BTCUSDT_UMCBL for futures)

Input Schema (JSON Schema)

{ "properties": { "symbol": { "description": "Trading pair symbol (e.g., BTCUSDT for spot, BTCUSDT_UMCBL for futures)", "type": "string" } }, "required": [ "symbol" ], "type": "object" }

Implementation Reference

  • Core handler implementation in BitgetRestClient that fetches current price for spot or futures symbols from Bitget API, with caching support.
    async getPrice(symbol: string): Promise<string> { const cacheKey = `price:${symbol}`; // Try cache first const cachedPrice = priceCache.get(cacheKey); if (cachedPrice) { return cachedPrice; } let price: string = ''; if (this.isFuturesSymbol(symbol)) { // Futures ticker const futuresSymbol = symbol.includes('_UMCBL') ? symbol : `${symbol}_UMCBL`; const response = await this.request<any>('GET', '/api/mix/v1/market/ticker', { symbol: futuresSymbol }); if (response.data?.last) { price = response.data.last; } else { throw new Error(`Price not found for symbol: ${symbol}`); } } else { // Spot ticker - use v1 public API const response = await this.request<any>('GET', '/api/spot/v1/market/tickers', {}); if (response.data && Array.isArray(response.data)) { const ticker = response.data.find((t: any) => t.symbol === symbol); if (ticker) { price = ticker.close; } else { throw new Error(`Price not found for symbol: ${symbol}`); } } else { throw new Error(`Price not found for symbol: ${symbol}`); } } // Cache the result priceCache.set(cacheKey, price); return price; }
  • MCP server dispatch handler for getPrice tool, validates input with schema and calls BitgetRestClient.getPrice.
    case 'getPrice': { const { symbol } = GetPriceSchema.parse(args); const price = await this.bitgetClient.getPrice(symbol); return { content: [ { type: 'text', text: `Current price for ${symbol}: $${price}`, }, ], } as CallToolResult; }
  • Zod schema for validating getPrice tool input (symbol parameter).
    export const GetPriceSchema = z.object({ symbol: z.string().describe('Trading pair symbol (e.g., BTCUSDT for spot, BTCUSDT_UMCBL for futures)') });
  • src/server.ts:103-113 (registration)
    Tool registration in listTools handler, defining name, description, and input schema for getPrice.
    { name: 'getPrice', description: 'Get current price for a trading pair (spot or futures)', inputSchema: { type: 'object', properties: { symbol: { type: 'string', description: 'Trading pair symbol (e.g., BTCUSDT for spot, BTCUSDT_UMCBL for futures)' } }, required: ['symbol'] }, },

Other Tools

Related Tools

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