get_all_mids
Retrieve mid prices for all available trading pairs on the exchange to access current market valuation data.
Instructions
Retrieve the mid prices for all trading pairs available on the exchange.
Parameters:
ctx (Context): The MCP context object for accessing server state.
Returns:
str: A JSON string containing a dictionary of trading pairs and their mid prices.
Returns a JSON string with an error message if the query fails.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"properties": {},
"type": "object"
}
Implementation Reference
- main.py:66-81 (handler)The async handler function implementing the get_all_mids tool. It calls info.all_mids() from the Hyperliquid SDK to fetch mid prices for all pairs and returns them as JSON, with error handling.async def get_all_mids(ctx: Context) -> str: """ Retrieve the mid prices for all trading pairs available on the exchange. Parameters: ctx (Context): The MCP context object for accessing server state. Returns: str: A JSON string containing a dictionary of trading pairs and their mid prices. Returns a JSON string with an error message if the query fails. """ try: all_mids = info.all_mids() return json.dumps(all_mids) except Exception as e: return json.dumps({"error": f"Failed to fetch all mids: {str(e)}"})
- main.py:65-65 (registration)The @mcp.tool() decorator that registers the get_all_mids function as a tool in the FastMCP server.@mcp.tool()