get_candle_snapshot
Retrieve candlestick data for a specific token on Hyperliquid exchange by specifying the token symbol, time interval, and start time. Analyze historical market trends and price movements.
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 | |
| endTime | No | End time in milliseconds since epoch (optional) | |
| interval | Yes | Time interval (e.g., '15m', '1h') | |
| startTime | Yes | Start time in milliseconds since epoch |
Implementation Reference
- src/actions.ts:26-36 (handler)The handler function that implements the core logic of the 'get_candle_snapshot' tool. It validates the input arguments using candleSnapshotSchema, fetches the candle snapshot data from the Hyperliquid client, and returns the JSON-stringified result.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 used for input validation and transformation in the get_candle_snapshot handler (transforms 'symbol' to 'coin').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/tools.ts:13-38 (registration)MCP Tool registration definition including 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:49-51 (registration)Registration of the tool handler in the CallToolRequest switch statement, dispatching to the getCandleSnapshot function.case "get_candle_snapshot": { return await getCandleSnapshot(hyperliquidClient, args); }