Skip to main content
Glama
ethancod1ng

Binance MCP Server

by ethancod1ng

get_price

Retrieve current market prices for trading pairs on Binance to monitor cryptocurrency values and make informed trading decisions.

Instructions

获取指定交易对的当前价格

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYes交易对符号,如 BTCUSDT

Implementation Reference

  • The asynchronous handler function that validates input, fetches the current price for the given symbol from the Binance client, and returns the price data with timestamp.
    handler: async (binanceClient: any, args: unknown) => {
      const input = validateInput(GetPriceSchema, args);
      validateSymbol(input.symbol);
    
      try {
        const price = await binanceClient.prices({ symbol: input.symbol });
        return {
          symbol: input.symbol,
          price: price[input.symbol],
          timestamp: Date.now(),
        };
      } catch (error) {
        handleBinanceError(error);
      }
    },
  • JSON Schema defining the input for the get_price tool, specifying the required 'symbol' string parameter.
    inputSchema: {
      type: 'object',
      properties: {
        symbol: {
          type: 'string',
          description: '交易对符号,如 BTCUSDT',
        },
      },
      required: ['symbol'],
    },
  • Zod schema for validating the get_price input, used within the handler.
    export const GetPriceSchema = z.object({
      symbol: z.string().describe('交易对符号,如 BTCUSDT'),
    });
  • The complete tool definition object for 'get_price', including name, description, inputSchema, and handler, within the marketDataTools export.
    {
      name: 'get_price',
      description: '获取指定交易对的当前价格',
      inputSchema: {
        type: 'object',
        properties: {
          symbol: {
            type: 'string',
            description: '交易对符号,如 BTCUSDT',
          },
        },
        required: ['symbol'],
      },
      handler: async (binanceClient: any, args: unknown) => {
        const input = validateInput(GetPriceSchema, args);
        validateSymbol(input.symbol);
    
        try {
          const price = await binanceClient.prices({ symbol: input.symbol });
          return {
            symbol: input.symbol,
            price: price[input.symbol],
            timestamp: Date.now(),
          };
        } catch (error) {
          handleBinanceError(error);
        }
      },
    },
  • src/server.ts:41-51 (registration)
    Server method that registers all tools, including get_price from marketDataTools, into the MCP server's tools Map.
    private setupTools(): void {
      const allTools = [
        ...marketDataTools,
        ...accountTools,
        ...tradingTools,
      ];
    
      for (const tool of allTools) {
        this.tools.set(tool.name, tool);
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It only states what the tool does (gets current price) without mentioning any behavioral traits like whether it's a read-only operation, potential rate limits, authentication requirements, error conditions, or what format the price is returned in. This is inadequate for a tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise - a single sentence that directly states the tool's purpose with zero wasted words. It's appropriately sized for a simple price lookup tool and is front-loaded with the core functionality.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and no output schema, the description is incomplete. For a price lookup tool, users need to know what format the price is returned in (decimal, string, with precision), whether it's real-time or delayed, and any authentication or rate limiting considerations. The description provides none of this context, making it inadequate despite the tool's apparent simplicity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description mentions '指定交易对' (specified trading pair) which aligns with the single 'symbol' parameter. However, with 100% schema description coverage (the schema already fully documents the symbol parameter), the description adds minimal value beyond what's in the schema. It doesn't provide additional context about valid symbol formats or examples beyond what the schema states.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as '获取指定交易对的当前价格' (get the current price of a specified trading pair), which is a specific verb+resource combination. It distinguishes from siblings like get_24hr_ticker (which provides 24-hour statistics) or get_orderbook (which provides order book data), though it doesn't explicitly mention these distinctions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to choose get_price over get_24hr_ticker for price data, or when other tools like get_klines might be more appropriate. There's no context about prerequisites or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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