get_all_mids
Retrieve current mid prices for all cryptocurrencies available on the Hyperliquid decentralized exchange to access real-time market data.
Instructions
Get current mid prices for all coins on Hyperliquid
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_all_mids"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- MCP tool handler for 'get_all_mids' that invokes the Hyperliquid client method and formats the response as MCP TextContent.
async def handle_get_all_mids(client: HyperliquidClient, args: Dict[str, Any]) -> Dict[str, Any]: """Handle get all mids request.""" result = await client.get_all_mids() if not result.success: raise ValueError(f"Failed to get mid prices: {result.error}") return { "content": [ TextContent( type="text", text=f"Mid prices for all coins:\n{json.dumps(result.data, indent=2)}", ) ] } - Tool schema definition (MCP Tool object) for 'get_all_mids', specifying no input parameters.
get_all_mids_tool = Tool( name="get_all_mids", description="Get current mid prices for all coins on Hyperliquid", inputSchema={ "type": "object", "properties": {}, "required": [], }, ) - HyperliquidClient helper method implementing the core API call to fetch all mid prices via POST /info.
async def get_all_mids(self) -> ApiResponse[AllMidsResponse]: """Get current mid prices for all coins.""" try: response = await self.client.post("/info", json={"type": "allMids"}) response.raise_for_status() return ApiResponse(success=True, data=response.json()) except Exception as e: return ApiResponse(success=False, error=str(e)) - hyperliquid_mcp_server/main.py:67-85 (registration)Registration of the 'get_all_mids' tool schema in the MCP server's list_tools() method.
@app.list_tools() async def list_tools() -> list: """List all available tools.""" return [ # Market data tools get_all_mids_tool, get_l2_book_tool, get_candle_snapshot_tool, # Account info tools get_open_orders_tool, get_user_fills_tool, get_user_fills_by_time_tool, get_portfolio_tool, # Trading tools place_order_tool, place_trigger_order_tool, cancel_order_tool, cancel_all_orders_tool, ] - hyperliquid_mcp_server/main.py:94-95 (registration)Dispatch/handling registration in the MCP server's call_tool() method for 'get_all_mids'.
if name == "get_all_mids": result = await handle_get_all_mids(client, args)