Skip to main content
Glama
ethancod1ng
by ethancod1ng

get_24hr_ticker

Retrieve 24-hour price change statistics for cryptocurrency trading pairs on Binance, including price movements and trading volume data.

Instructions

获取24小时价格变动统计

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolNo交易对符号,不传则获取所有交易对

Implementation Reference

  • The handler function for the 'get_24hr_ticker' tool. It validates input using Get24hrTickerSchema, optionally validates symbol, fetches 24hr ticker stats from Binance API using dailyStats, handles single symbol or all, and returns formatted data with timestamp or propagates errors.
    handler: async (binanceClient: any, args: unknown) => { const input = validateInput(Get24hrTickerSchema, args); if (input.symbol) { validateSymbol(input.symbol); } try { if (input.symbol) { const ticker = await binanceClient.dailyStats({ symbol: input.symbol }); return { symbol: input.symbol, data: ticker, timestamp: Date.now(), }; } else { const tickers = await binanceClient.dailyStats(); return { data: Array.isArray(tickers) ? tickers : [tickers], timestamp: Date.now(), }; } } catch (error) { handleBinanceError(error); }
  • The inputSchema defined for the MCP tool 'get_24hr_ticker', specifying optional symbol parameter.
    inputSchema: { type: 'object', properties: { symbol: { type: 'string', description: '交易对符号,不传则获取所有交易对', }, }, required: [], },
  • Zod schema Get24hrTickerSchema used for input validation in the handler.
    export const Get24hrTickerSchema = z.object({ symbol: z.string().optional().describe('交易对符号,不传则获取所有交易对'), });
  • src/server.ts:48-50 (registration)
    Registration loop in MCP server setupTools() that adds 'get_24hr_ticker' (from marketDataTools) to the tools Map by name for handling list_tools and call_tool requests.
    for (const tool of allTools) { this.tools.set(tool.name, tool); }
  • src/server.ts:42-46 (registration)
    Combines tool arrays including marketDataTools (containing get_24hr_ticker) for registration in MCP server.
    const allTools = [ ...marketDataTools, ...accountTools, ...tradingTools, ];

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