get_all_mids
Retrieve mid prices for all trading pairs on the exchange to monitor current market valuations and support trading decisions.
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
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- main.py:65-81 (handler)The handler function for the 'get_all_mids' tool, decorated with @mcp.tool() for registration. It fetches mid prices for all trading pairs using the Hyperliquid Info SDK's all_mids() method and returns the result as a JSON string, with error handling.@mcp.tool() 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)}"})