get_futures_funding_rate
Retrieve the current funding rate for Binance futures trading pairs to monitor costs and inform trading decisions.
Instructions
Get current funding rate for a futures trading pair
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | Trading pair symbol (e.g., BTCUSDT) |
Implementation Reference
- src/connectors/binance-rest.ts:151-167 (handler)Core implementation of the get_futures_funding_rate tool. Fetches the current funding rate from the Binance Futures /premiumIndex API endpoint using axios with exponential backoff retry logic.public async getFuturesFundingRate(symbol: string): Promise<any> { try { logger.info(`Getting futures funding rate for ${symbol}`); const response = await this.executeWithRetry(() => this.axiosInstance.get(`${config.FUTURES_REST_URL}/premiumIndex`, { params: { symbol: symbol.toUpperCase() } }) ); logger.info('Successfully fetched funding rate data'); return response.data; } catch (error) { logger.error('Error fetching funding rate:', error); throw new APIError('Failed to fetch funding rate data', error as Error); } }
- src/index.ts:94-107 (registration)Tool registration in the ListTools handler, defining the tool name, description, and input schema.{ name: "get_futures_funding_rate", description: "Get current funding rate for a futures trading pair", inputSchema: { type: "object", properties: { symbol: { type: "string", description: "Trading pair symbol (e.g., BTCUSDT)" } }, required: ["symbol"] } },
- src/index.ts:223-235 (handler)MCP server handler for the get_futures_funding_rate tool call. Validates input, delegates to BinanceRestConnector, and formats response.case "get_futures_funding_rate": { if (!isFuturesDataParams(request.params.arguments)) { throw new Error('Invalid futures data parameters'); } const { symbol } = request.params.arguments; const data = await restConnector.getFuturesFundingRate(symbol); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; }
- src/types/api-types.ts:19-21 (schema)TypeScript interface defining the input parameters for futures tools like get_futures_funding_rate.export interface FuturesDataParams { symbol: string; }
- src/types/api-types.ts:58-63 (schema)Type guard function used to validate input parameters for the get_futures_funding_rate tool.export function isFuturesDataParams(params: any): params is FuturesDataParams { return ( typeof params === 'object' && typeof params.symbol === 'string' ); }