Skip to main content
Glama

Binance MCP Server

ticker24hr.ts1.73 kB
// src/tools/binance-spot/market-api/ticker24hr.ts import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { z } from "zod"; import { spotClient } from "../../../config/binanceClient.js"; export function registerBinanceTicker24hr(server: McpServer) { server.tool( "BinanceTicker24hr", "Get 24-hour price change statistics for a symbol or all symbols.", { symbol: z.string().optional().describe("Symbol of the trading pair (e.g., BTCUSDT)") }, async ({ symbol }) => { try { const params: any = {}; if (symbol) params.symbol = symbol; const response = await spotClient.restAPI.ticker24hr(params); const data = await response.data(); const isArray = Array.isArray(data); const responseText = isArray ? `Retrieved 24hr statistics for all symbols. Total items: ${data.length}.` : `Retrieved 24hr statistics for ${symbol}.`; return { content: [ { type: "text", text: `${responseText} Response: ${JSON.stringify(data)}` } ] }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to retrieve 24hr ticker: ${errorMessage}` } ], isError: true }; } } ); }

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

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