Skip to main content
Glama
ethancod1ng
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); } }

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