Skip to main content
Glama
gagarinyury

MCP Bitget Trading Server

by gagarinyury

getPrice

Retrieve current market prices for cryptocurrency trading pairs on Bitget exchange, supporting both spot and futures contracts.

Instructions

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

Input Schema

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

Implementation Reference

  • MCP tool handler for getPrice that parses input arguments using the schema and delegates execution to the BitgetRestClient's getPrice method, returning formatted result.
    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 defining the input parameters for the getPrice tool (symbol string). Used for validation in the handler.
    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)
    Registration of the getPrice tool in the listTools handler, providing name, description, and input schema for MCP discovery.
    {
      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']
      },
    },
  • The core getPrice implementation in BitgetRestClient class. Handles caching, spot vs futures logic, API requests to Bitget, and error handling.
    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;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but offers minimal behavioral context. It doesn't disclose whether this is a real-time or cached price, rate limits, authentication requirements, error conditions, or response format. 'Get current price' suggests a read operation but lacks operational details.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Extremely concise single sentence with zero waste. Every word earns its place: 'Get' (action), 'current price' (what), 'for a trading pair' (scope), '(spot or futures)' (clarification). Front-loaded with core purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a financial data tool with no annotations and no output schema, the description is insufficient. It doesn't explain what 'current price' means (last trade? bid? ask?), latency, data sources, or return format. Given the complexity of trading systems and sibling tools, more context is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already fully documents the single parameter. The description adds no additional parameter semantics beyond what's in the schema (e.g., no examples beyond the schema's, no clarification on symbol conventions). Baseline 3 is appropriate when schema does the work.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Get') and resource ('current price for a trading pair'), specifying both spot and futures markets. It distinguishes from some siblings like getTicker (which might return more data) and getOrderBook (which shows depth), but doesn't explicitly differentiate from all price-related tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for price retrieval, but provides no explicit guidance on when to use this versus alternatives like getTicker or getCandles. No prerequisites, exclusions, or comparison to siblings are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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