get_prices
Retrieve current mid prices for all outcome coins to evaluate prediction market conditions.
Instructions
Get current mid prices for all outcome coins
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- mcp-server.ts:158-173 (registration)Registration of the 'get_prices' tool on the MCP server. The tool uses an empty schema (no parameters) and fetches all mid prices via hlInfo, filtering for outcome coins (prefixed with '#'), sorting them, converting to percentage format, and returning them as text.
// --- get_prices --- server.tool( 'get_prices', 'Get current mid prices for all outcome coins', {}, async () => { const mids = await hlInfo<Record<string, string>>({ type: 'allMids' }); const outcomeMids = Object.entries(mids) .filter(([coin]) => coin.startsWith('#')) .sort(([a], [b]) => a.localeCompare(b)) .map(([coin, px]) => `${coin}: ${(parseFloat(px) * 100).toFixed(2)}%`) .join('\n'); return { content: [{ type: 'text', text: outcomeMids || 'No outcome prices found' }] }; }, ); - mcp-server.ts:163-172 (handler)Handler function for get_prices. Calls hlInfo<Record<string,string>>({type:'allMids'}) to fetch all mid prices from Hyperliquid, filters for outcome coins (starting with '#'), sorts alphabetically, converts prices to percentages (×100), and returns formatted text. Returns 'No outcome prices found' if none exist.
async () => { const mids = await hlInfo<Record<string, string>>({ type: 'allMids' }); const outcomeMids = Object.entries(mids) .filter(([coin]) => coin.startsWith('#')) .sort(([a], [b]) => a.localeCompare(b)) .map(([coin, px]) => `${coin}: ${(parseFloat(px) * 100).toFixed(2)}%`) .join('\n'); return { content: [{ type: 'text', text: outcomeMids || 'No outcome prices found' }] }; }, - mcp-server.ts:21-29 (helper)The hlInfo helper function used by get_prices to make POST requests to the Hyperliquid API /info endpoint with typed generic response.
async function hlInfo<T>(body: object): Promise<T> { const res = await fetch(`${API_URL}/info`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body), }); if (!res.ok) throw new Error(`HL API error: ${res.status}`); return res.json() as Promise<T>; } - mcp-server.ts:162-162 (schema)Empty input schema ({}) for get_prices – the tool takes no parameters.
{},