Skip to main content
Glama
t3rmed

Hyperliquid MCP Server

by t3rmed

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

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))
  • 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,
        ]
  • 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)

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/t3rmed/hyperliquid-mcp'

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