Skip to main content
Glama
mixuechu

Binance MCP Server

by mixuechu

get_trade_history

Retrieve recent cryptocurrency trade data for a specific trading pair on Binance to analyze market activity and transaction history.

Instructions

Get recent trade history for a pair.

Args: symbol: The trading pair. limit: Number of trades to fetch.

Returns: List of trade summaries.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYes
limitNo

Implementation Reference

  • The main handler function for the 'get_trade_history' tool. It is decorated with @mcp.tool() for registration and implements fetching the user's recent trade history from the Binance API endpoint /api/v3/myTrades using HMAC-signed authentication.
    @mcp.tool()
    def get_trade_history(symbol: str, limit: int = 10) -> Any:
        """
        Get recent trade history for a pair.
    
        Args:
            symbol: The trading pair.
            limit: Number of trades to fetch.
    
        Returns:
            List of trade summaries.
        """
        url = "https://api.binance.com/api/v3/myTrades"
        timestamp = int(time.time() * 1000)
        params = {
            "symbol": symbol,
            "limit": limit,
            "timestamp": timestamp
        }
        query_string = "&".join([f"{k}={v}" for k, v in params.items()])
        signature = hmac.new(BINANCE_SECRET_KEY.encode(), query_string.encode(), hashlib.sha256).hexdigest()
        params["signature"] = signature
        headers = {"X-MBX-APIKEY": BINANCE_API_KEY}
        response = requests.get(url, headers=headers, params=params)
        if response.status_code == 200:
            return [
                {
                    "time": trade["time"],
                    "side": "BUY" if trade["isBuyer"] else "SELL",
                    "qty": trade["qty"],
                    "price": trade["price"]
                } for trade in response.json()
            ]
        return {"error": response.text}
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 states it 'fetches' trades, implying a read-only operation, but doesn't specify permissions needed, rate limits, data freshness, or error conditions. This is inadequate for a tool that accesses historical trade data.

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

Conciseness4/5

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

The description is appropriately sized and front-loaded with the core purpose in the first sentence. The Args/Returns sections are structured but slightly verbose; every sentence adds value, though it could be more streamlined (e.g., integrating parameter details into the main text).

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 complexity of trading data, no annotations, no output schema, and low schema coverage, the description is incomplete. It lacks details on return format (e.g., what fields are in 'trade summaries'), error handling, and behavioral traits like rate limits or authentication needs, which are critical for this context.

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 adds basic meaning for both parameters ('symbol: The trading pair' and 'limit: Number of trades to fetch'), which is valuable since schema description coverage is 0%. However, it doesn't provide format details (e.g., symbol syntax like 'BTC/USD'), constraints (e.g., limit range), or examples, leaving gaps in parameter understanding.

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 verb ('Get') and resource ('recent trade history for a pair'), making the purpose specific and understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_open_orders' or 'get_funding_rate_history', which also retrieve trading data but for different resources.

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 prerequisites, timing considerations, or compare it to siblings like 'get_open_orders' for active trades or 'get_funding_rate_history' for other historical data, leaving usage context unclear.

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

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