fetchTickers
Retrieve current market prices and trading data for cryptocurrency pairs from supported exchanges, enabling real-time market analysis and trading decisions.
Instructions
Fetch all tickers from an exchange
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| exchangeId | Yes | Exchange ID (e.g., 'binance', 'coinbase') | |
| symbols | No | Optional list of specific symbols to fetch |
Implementation Reference
- src/tools/market-tools.ts:92-117 (handler)The handler function that executes the fetchTickers tool logic: gets public exchange instance via ccxtServer and calls exchange.fetchTickers(symbols), returns JSON stringified tickers or error.async ({ exchangeId, symbols }) => { try { // 공개 인스턴스 사용 const exchange = ccxtServer.getPublicExchangeInstance(exchangeId); const tickers = await exchange.fetchTickers(symbols); return { content: [ { type: "text", text: JSON.stringify(tickers, null, 2) } ] }; } catch (error) { return { content: [ { type: "text", text: `Error fetching tickers: ${(error as Error).message}` } ], isError: true }; } }
- src/tools/market-tools.ts:88-91 (schema)Input schema using Zod for fetchTickers tool: exchangeId (string), symbols (optional string array).{ exchangeId: z.string().describe("Exchange ID (e.g., 'binance', 'coinbase')"), symbols: z.array(z.string()).optional().describe("Optional list of specific symbols to fetch") },
- src/tools/market-tools.ts:85-118 (registration)The server.tool() call that registers the fetchTickers MCP tool, specifying name, description, input schema, and handler function.server.tool( "fetchTickers", "Fetch all tickers from an exchange", { exchangeId: z.string().describe("Exchange ID (e.g., 'binance', 'coinbase')"), symbols: z.array(z.string()).optional().describe("Optional list of specific symbols to fetch") }, async ({ exchangeId, symbols }) => { try { // 공개 인스턴스 사용 const exchange = ccxtServer.getPublicExchangeInstance(exchangeId); const tickers = await exchange.fetchTickers(symbols); return { content: [ { type: "text", text: JSON.stringify(tickers, null, 2) } ] }; } catch (error) { return { content: [ { type: "text", text: `Error fetching tickers: ${(error as Error).message}` } ], isError: true }; } } );
- src/server.ts:372-372 (registration)Top-level call to registerMarketTools(server, ccxtServer), which in turn registers the fetchTickers tool among other market tools.registerMarketTools(this.server, this);