Skip to main content
Glama
ethancod1ng

Binance MCP Server

by ethancod1ng

get_account_info

Retrieve your Binance account details and current balance information through the MCP server integration.

Instructions

获取账户信息和余额

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function executes the tool logic: validates input using GetAccountInfoSchema, fetches account information from Binance API, filters balances with non-zero free or locked amounts, computes total, and returns formatted account details including commissions, permissions, and balances.
    handler: async (binanceClient: any, args: unknown) => {
      validateInput(GetAccountInfoSchema, args);
    
      try {
        const accountInfo = await binanceClient.accountInfo();
        
        return {
          makerCommission: accountInfo.makerCommission,
          takerCommission: accountInfo.takerCommission,
          buyerCommission: accountInfo.buyerCommission,
          sellerCommission: accountInfo.sellerCommission,
          canTrade: accountInfo.canTrade,
          canWithdraw: accountInfo.canWithdraw,
          canDeposit: accountInfo.canDeposit,
          updateTime: accountInfo.updateTime,
          accountType: accountInfo.accountType,
          permissions: accountInfo.permissions,
          balances: accountInfo.balances
            .filter((balance: any) => parseFloat(balance.free) > 0 || parseFloat(balance.locked) > 0)
            .map((balance: any) => ({
              asset: balance.asset,
              free: balance.free,
              locked: balance.locked,
              total: (parseFloat(balance.free) + parseFloat(balance.locked)).toString(),
            })),
          timestamp: Date.now(),
        };
      } catch (error) {
        handleBinanceError(error);
      }
    },
  • The get_account_info tool is registered as the first entry in the exported accountTools array, which is later spread into the server's tool map.
    {
      name: 'get_account_info',
      description: '获取账户信息和余额',
      inputSchema: {
        type: 'object',
        properties: {},
        required: [],
      },
      handler: async (binanceClient: any, args: unknown) => {
        validateInput(GetAccountInfoSchema, args);
    
        try {
          const accountInfo = await binanceClient.accountInfo();
          
          return {
            makerCommission: accountInfo.makerCommission,
            takerCommission: accountInfo.takerCommission,
            buyerCommission: accountInfo.buyerCommission,
            sellerCommission: accountInfo.sellerCommission,
            canTrade: accountInfo.canTrade,
            canWithdraw: accountInfo.canWithdraw,
            canDeposit: accountInfo.canDeposit,
            updateTime: accountInfo.updateTime,
            accountType: accountInfo.accountType,
            permissions: accountInfo.permissions,
            balances: accountInfo.balances
              .filter((balance: any) => parseFloat(balance.free) > 0 || parseFloat(balance.locked) > 0)
              .map((balance: any) => ({
                asset: balance.asset,
                free: balance.free,
                locked: balance.locked,
                total: (parseFloat(balance.free) + parseFloat(balance.locked)).toString(),
              })),
            timestamp: Date.now(),
          };
        } catch (error) {
          handleBinanceError(error);
        }
      },
    },
  • Zod schema definition for GetAccountInfo input, which is an empty object since no parameters are required.
    export const GetAccountInfoSchema = z.object({});
  • Inline JSON schema provided in the tool registration for input validation, matching the empty object schema.
    inputSchema: {
      type: 'object',
      properties: {},
      required: [],
    },
  • src/server.ts:42-50 (registration)
    In the server's setupTools method, accountTools (containing get_account_info) is spread into allTools and each tool is registered in a Map by name for handling tool calls.
    const allTools = [
      ...marketDataTools,
      ...accountTools,
      ...tradingTools,
    ];
    
    for (const tool of allTools) {
      this.tools.set(tool.name, tool);
    }

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/ethancod1ng/binance-mcp-server'

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