Skip to main content
Glama

get_ticker

Retrieve real-time trading data including price, bid/ask spread, and volume for cryptocurrency pairs on supported exchanges like MEXC, Gate.io, Bitget, and Kraken.

Instructions

Get real-time price, bid/ask, spread, and volume for a trading pair on a supported exchange

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
exchangeYesExchange to query. Supported: mexc, gateio, bitget, kraken
symbolYesTrading pair symbol (e.g., BTC/USDT, INDY/USDT)

Implementation Reference

  • Main tool registration and handler implementation. Validates exchange and symbol parameters, fetches ticker data via connector.getTicker(), and returns formatted JSON with price, bid/ask, spread, volume, and timestamp.
    server.tool(
      'get_ticker',
      'Get real-time price, bid/ask, spread, and volume for a trading pair on a supported exchange',
      {
        exchange: ExchangeParam,
        symbol: SymbolParam,
      },
      async ({ exchange, symbol }) => {
        const validExchange = validateExchange(exchange);
        const validSymbol = validateSymbol(symbol);
    
        const connector = await getConnectorSafe(exchange);
        const ticker = await connector.getTicker(validSymbol);
    
        return {
          content: [
            {
              type: 'text' as const,
              text: JSON.stringify(
                {
                  symbol: ticker.symbol,
                  last: ticker.last,
                  bid: ticker.bid,
                  ask: ticker.ask,
                  spread: ticker.ask - ticker.bid,
                  spreadPercent: ((ticker.ask - ticker.bid) / ticker.ask) * 100,
                  baseVolume: ticker.baseVolume,
                  quoteVolume: ticker.quoteVolume,
                  timestamp: ticker.timestamp,
                  exchange: validExchange,
                },
                null,
                2
              ),
            },
          ],
        };
      }
    );
  • Zod schema definitions for tool input parameters. ExchangeParam validates supported exchanges (mexc, gateio, bitget, kraken). SymbolParam validates trading pair symbols like BTC/USDT.
    export const ExchangeParam = z
      .string()
      .describe('Exchange to query. Supported: mexc, gateio, bitget, kraken');
    
    export const SymbolParam = z.string().describe('Trading pair symbol (e.g., BTC/USDT, INDY/USDT)');
  • Registers all tool categories with the MCP server, including registerMarketDataTools which contains get_ticker.
    export function registerTools(server: McpServer): void {
      registerMarketDataTools(server);
      registerAccountTools(server);
      registerTradingTools(server);
      registerCardanoTools(server);
      registerStrategyTools(server);
    }
  • Helper functions to validate exchange names and safely instantiate exchange connectors. Used by get_ticker handler to fetch data from the correct exchange.
    export function validateExchange(exchange: string): SupportedExchange {
      const lower = exchange.toLowerCase();
      if (!(SUPPORTED_EXCHANGES as readonly string[]).includes(lower)) {
        throw new Error(
          `Unsupported exchange: ${exchange}. Supported: ${SUPPORTED_EXCHANGES.join(', ')}`
        );
      }
      return lower as SupportedExchange;
    }
    
    export async function getConnectorSafe(exchange: string): Promise<BaseExchangeConnector> {
      const validExchange = validateExchange(exchange);
      const { ExchangeFactory } = await import('@3rd-eye-labs/openmm');
      try {
        return await ExchangeFactory.getExchange(validExchange as any);
      } catch (error) {
        const message = error instanceof Error ? error.message : String(error);
        throw new Error(`Failed to connect to ${validExchange}: ${message}`);
      }
    }
  • Symbol validation helper that checks format and converts to uppercase. Used by get_ticker to validate the trading pair symbol.
    export function validateSymbol(symbol: string): string {
      if (!symbol) {
        throw new Error('Symbol is required');
      }
      const upper = symbol.toUpperCase();
      if (!/^[A-Z]+\/[A-Z]+$/.test(upper) && !/^[A-Z]+[A-Z]+$/.test(upper)) {
        throw new Error(`Invalid symbol format: ${symbol}. Expected: BTC/USDT or BTCUSDT`);
      }
      return upper;
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'real-time' data, which is useful context, but fails to disclose other critical traits such as rate limits, authentication requirements, error handling, or data freshness guarantees. For a read operation with no annotation coverage, this leaves significant gaps in understanding its behavior.

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?

The description is a single, front-loaded sentence that efficiently conveys the tool's purpose without any wasted words. Every part of the sentence earns its place by specifying the data retrieved and the context (supported exchange), making it appropriately sized and structured.

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

Completeness3/5

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

Given the tool's low complexity (2 parameters, no nested objects) and 100% schema coverage, the description is adequate but not complete. It lacks output schema, so return values are undocumented, and with no annotations, behavioral aspects like rate limits or errors are missing. For a simple read tool, it meets minimum viability but has clear gaps in contextual information.

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%, with both parameters (exchange and symbol) well-documented in the schema. The description adds no additional meaning beyond what the schema provides (e.g., it doesn't explain format nuances or constraints). According to the rules, with high schema coverage, the baseline is 3 even without param info in the description.

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

Purpose5/5

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

The description clearly states the specific action ('Get') and resource ('real-time price, bid/ask, spread, and volume for a trading pair'), distinguishing it from siblings like get_balance (balances), get_orderbook (order book data), and get_trades (trade history). It precisely defines what data is retrieved without being vague or tautological.

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 by specifying 'on a supported exchange,' which provides some context for when to use this tool (for real-time market data on those exchanges). However, it does not explicitly state when to use it versus alternatives like get_orderbook (for depth data) or get_cardano_price (for a specific asset's price), nor does it mention exclusions or prerequisites.

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/QBT-Labs/openmm-mcp'

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