get_recent_trades
Fetch recent cryptocurrency trades for a specific trading pair from Binance to analyze market activity and trading patterns.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"symbol": "<symbol>"
},
"name": "get_recent_trades"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | Trading pair symbol, e.g. BTCUSDT | |
| limit | No | Number of trades to return, default 500, max 1000 |
Implementation Reference
- src/index.ts:48-66 (handler)Handler function that calls the Binance API /api/v3/trades endpoint to retrieve recent trades for a given symbol, with optional limit, handles errors, and returns JSON-formatted response.
async (args: { symbol: string; limit?: number }) => { try { const response = await axios.get(`${BASE_URL}/api/v3/trades`, { params: { symbol: args.symbol, limit: args.limit }, proxy: getProxy(), }); return { content: [{ type: "text", text: JSON.stringify(response.data, null, 2) }] }; } catch (error: any) { return { content: [{ type: "text", text: `Failed to get recent trades: ${error.message}` }], isError: true }; } } - src/index.ts:44-47 (schema)Zod schema defining input parameters for the get_recent_trades tool: symbol (required string) and limit (optional number).
{ symbol: z.string().describe("Trading pair symbol, e.g. BTCUSDT"), limit: z.number().optional().describe("Number of trades to return, default 500, max 1000") }, - src/index.ts:42-67 (registration)Registration of the get_recent_trades tool using McpServer.tool method, including inline schema and handler.
server.tool( "get_recent_trades", { symbol: z.string().describe("Trading pair symbol, e.g. BTCUSDT"), limit: z.number().optional().describe("Number of trades to return, default 500, max 1000") }, async (args: { symbol: string; limit?: number }) => { try { const response = await axios.get(`${BASE_URL}/api/v3/trades`, { params: { symbol: args.symbol, limit: args.limit }, proxy: getProxy(), }); return { content: [{ type: "text", text: JSON.stringify(response.data, null, 2) }] }; } catch (error: any) { return { content: [{ type: "text", text: `Failed to get recent trades: ${error.message}` }], isError: true }; } } );