get_candle_snapshot
Retrieve candlestick data for specific tokens on Hyperliquid exchange to analyze price movements and market trends over defined time intervals.
Instructions
Get candlestick data for a token on Hyperliquid
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| coin | Yes | The symbol of the token to get candlestick data for | |
| interval | Yes | Time interval (e.g., '15m', '1h') | |
| startTime | Yes | Start time in milliseconds since epoch | |
| endTime | No | End time in milliseconds since epoch (optional) |
Implementation Reference
- src/actions.ts:26-36 (handler)The main handler function that validates the input arguments using candleSnapshotSchema, fetches the candle snapshot data from the Hyperliquid client, and returns a formatted response.export async function getCandleSnapshot( hyperliquidClient: PublicClient, args: unknown ) { const validatedArgs = candleSnapshotSchema.parse(args); const candleSnapshot = await hyperliquidClient.candleSnapshot(validatedArgs); return { content: [{ type: "text", text: JSON.stringify(candleSnapshot) }], isError: false, }; }
- src/schemas.ts:3-16 (schema)Zod schema for validating and transforming the input arguments (symbol to coin) for the get_candle_snapshot tool.export const candleSnapshotSchema = z .object({ symbol: z.string({ required_error: "Symbol must be a string" }), interval: z.string({ required_error: "Interval must be a string" }), startTime: z.number({ required_error: "Start time must be a number" }), endTime: z.number().nullable().optional(), }) .strict() .transform((data) => ({ coin: data.symbol, interval: data.interval, startTime: data.startTime, endTime: data.endTime, }));
- src/index.ts:49-51 (registration)Registration of the tool handler in the switch statement of the CallToolRequest handler.case "get_candle_snapshot": { return await getCandleSnapshot(hyperliquidClient, args); }
- src/tools.ts:13-38 (schema)MCP Tool definition including the name, description, and input schema for get_candle_snapshot.export const CANDLE_SNAPSHOT_TOOL: Tool = { name: "get_candle_snapshot", description: "Get candlestick data for a token on Hyperliquid", inputSchema: { type: "object", properties: { coin: { type: "string", description: "The symbol of the token to get candlestick data for", }, interval: { type: "string", description: "Time interval (e.g., '15m', '1h')", }, startTime: { type: "number", description: "Start time in milliseconds since epoch", }, endTime: { type: "number", description: "End time in milliseconds since epoch (optional)", }, }, required: ["coin", "interval", "startTime"], }, };
- src/index.ts:75-80 (registration)Registration of the tool in the ListToolsRequest handler, including CANDLE_SNAPSHOT_TOOL in the returned tools list.server.setRequestHandler(ListToolsRequestSchema, async () => { console.error("Received ListToolsRequest"); return { tools: [ALL_MIDS_TOOL, CANDLE_SNAPSHOT_TOOL, L2_BOOK_TOOL], }; });