Skip to main content
Glama
qeinfinity

Binance MCP Server

by qeinfinity

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
NameRequiredDescriptionDefault
symbolYesTrading pair symbol (e.g., BTCUSDT)

Implementation Reference

  • 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"]
      }
    },
  • 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)
        }]
      };
    }
  • TypeScript interface defining the input parameters for futures tools like get_futures_funding_rate.
    export interface FuturesDataParams {
      symbol: string;
    }
  • 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'
      );
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/qeinfinity/binance-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server