Skip to main content
Glama
aahl

OKX MCP Server

by aahl

Get market tickers

market_tickers

Retrieve real-time cryptocurrency market data including prices, bid/ask spreads, and 24-hour trading volumes. Sort and rank coins by price changes or trading activity to identify market trends.

Instructions

Retrieve the latest price snapshot, best bid/ask price, and trading volume in the last 24 hours.Get the ranking of coins with the highest increase or the largest trading volume.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
instTypeNoInstrument type: [SPOT/SWAP/FUTURES/OPTION]SPOT
instFamilyNoInstrument family。 Applicable to FUTURES/SWAP/OPTION
sortByNoSorting method: [change24h/changeMax/last/vol24h/...]change24h
limitNoNumber of results. Default: 30

Implementation Reference

  • The core handler function for the 'market_tickers' tool. It calls the OKX MarketAPI.get_tickers, processes the data by calculating change24h and changeMax, sorts by the specified field, limits the results, and includes a response schema.
    def market_tickers(
        instType: str = Field("SPOT", description="Instrument type: [SPOT/SWAP/FUTURES/OPTION]"),
        instFamily: str = Field("", description="Instrument family。 Applicable to FUTURES/SWAP/OPTION"),
        sortBy: str = Field("change24h", description="Sorting method: [change24h/changeMax/last/vol24h/...]"),
        limit: int | str = Field(30, description="Number of results. Default: 30"),
    ):
        resp = ACCOUNT.get_tickers(instType=instType, instFamily=instFamily) or {}
        if int(resp.get("code", 0)):
            return resp
        data = resp.get("data", [])
        for item in data:
            try:
                item["change24h"] = round((float(item["last"]) - float(item["open24h"])) / float(item["open24h"]) * 100, 2)
                item["changeMax"] = round((float(item["high24h"]) - float(item["low24h"])) / float(item["low24h"]) * 100, 2)
            except Exception:
                continue
        data.sort(key=lambda x: float(x.get(sortBy) or 0), reverse=True)
        resp["data"] = data[:int(limit)]
        resp["_response_schema"] = """
        instType	String	Instrument type
        instId	String	Instrument ID
        last	String	Last traded price
        lastSz	String	Last traded size. 0 represents there is no trading volume
        askPx	String	Best ask price
        askSz	String	Best ask size
        bidPx	String	Best bid price
        bidSz	String	Best bid size
        open24h	String	Open price in the past 24 hours
        high24h	String	Highest price in the past 24 hours
        low24h	String	Lowest price in the past 24 hours
        volCcy24h	String	24h trading volume, with a unit of currency.
            If it is a derivatives contract, the value is the number of base currency. e.g. the unit is BTC for BTC-USD-SWAP and BTC-USDT-SWAP
            If it is SPOT/MARGIN, the value is the quantity in quote currency.
        vol24h	String	24h trading volume, with a unit of contract.
            If it is a derivatives contract, the value is the number of contracts.
            If it is SPOT/MARGIN, the value is the quantity in base currency.
        sodUtc0	String	Open price in the UTC 0
        sodUtc8	String	Open price in the UTC 8
        change24h   float   Percentage change over 24 hours
        changeMax   float   24-hour high and low percentage range
        """
        return resp
  • Tool schema definition including title, description, and input parameters with Pydantic Field validations for the market_tickers tool.
    @mcp.tool(
        title="Get market tickers",
        description="Retrieve the latest price snapshot, best bid/ask price, and trading volume in the last 24 hours."
                    "Get the ranking of coins with the highest increase or the largest trading volume.",
    )
    def market_tickers(
        instType: str = Field("SPOT", description="Instrument type: [SPOT/SWAP/FUTURES/OPTION]"),
        instFamily: str = Field("", description="Instrument family。 Applicable to FUTURES/SWAP/OPTION"),
        sortBy: str = Field("change24h", description="Sorting method: [change24h/changeMax/last/vol24h/...]"),
        limit: int | str = Field(30, description="Number of results. Default: 30"),
    ):
  • Registration of the market tools (including market_tickers) by calling add_tools on the FastMCP instance.
    market.add_tools(mcp)
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It describes what data is retrieved but doesn't mention rate limits, authentication requirements, data freshness, error conditions, or whether this is a read-only operation. For a market data tool with zero annotation coverage, this leaves significant behavioral gaps.

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

Conciseness4/5

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

The description is efficiently structured in two sentences that directly state the tool's purpose. The first sentence covers core functionality, the second adds ranking capability. No wasted words, though it could be slightly more front-loaded by mentioning ranking earlier.

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 market data tool with 4 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain what the output looks like, how results are formatted, whether pagination exists, or any error scenarios. The agent would need to guess about return values and behavioral characteristics.

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 documents all 4 parameters with their types, defaults, and brief descriptions. The description mentions 'ranking of coins' which aligns with the sortBy parameter's purpose, but doesn't add meaningful semantic context beyond what the schema provides. Baseline 3 is appropriate when schema does the heavy lifting.

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 tool retrieves market data including price snapshot, bid/ask prices, and 24-hour trading volume, with specific mention of ranking coins by increase or volume. It uses specific verbs like 'retrieve' and 'get' with clear resources. However, it doesn't explicitly differentiate from sibling tools like account_balance or get_order_list, which focus on account/order data rather than market data.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, context for market analysis, or how it differs from sibling tools like get_trade_order or place_order. There's no explicit when/when-not usage information, leaving the agent to infer based on tool names alone.

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/aahl/mcp-okx'

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