get_market_info
Retrieve real-time perpetual market data including price, funding rate, open interest, and 24-hour volume for a specified trading symbol.
Instructions
Get current price, funding rate, open interest, and 24h volume for a perpetual market
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | Market symbol (e.g. BTC, ETH, SOL) |
Implementation Reference
- src/hyperliquid_mcp/client.py:65-84 (handler)The main handler function that executes the get_market_info tool logic. It retrieves market data (price, funding rate, open interest, volume) from the Hyperliquid API by calling meta_and_asset_ctxs() and matching the symbol.
def get_market_info(self, symbol: str) -> dict[str, Any]: """Get price, funding rate, and 24h volume for a market.""" metas_and_contexts = self.info.meta_and_asset_ctxs() meta = metas_and_contexts[0] ctxs = metas_and_contexts[1] for i, asset in enumerate(meta.get("universe", [])): if asset["name"].upper() == symbol.upper(): ctx = ctxs[i] if i < len(ctxs) else {} return { "symbol": asset["name"], "mark_price": ctx.get("markPx", "N/A"), "mid_price": ctx.get("midPx", "N/A"), "oracle_price": ctx.get("oraclePx", "N/A"), "funding_rate": ctx.get("funding", "N/A"), "open_interest": ctx.get("openInterest", "N/A"), "day_volume": ctx.get("dayNtlVlm", "N/A"), "max_leverage": asset.get("maxLeverage", 1), } raise ValueError(f"Market '{symbol}' not found. Use list_markets to see available markets.") - src/hyperliquid_mcp/server.py:32-42 (schema)The JSON schema definition for the get_market_info tool input. Defines the 'symbol' parameter as a required string with description.
Tool( name="get_market_info", description="Get current price, funding rate, open interest, and 24h volume for a perpetual market", inputSchema={ "type": "object", "properties": { "symbol": {"type": "string", "description": "Market symbol (e.g. BTC, ETH, SOL)"}, }, "required": ["symbol"], }, ), - src/hyperliquid_mcp/server.py:137-138 (registration)The dispatch case that routes get_market_info tool calls to the client implementation. Extracts the 'symbol' argument and calls client.get_market_info().
case "get_market_info": return client.get_market_info(args["symbol"])