fetchTickers
Fetch real-time ticker data from any exchange, including price, volume, and market statistics. Specify exchange and symbols for targeted results using the CCXT MCP Server.
Instructions
Fetch all tickers from an exchange
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| exchangeId | Yes | Exchange ID (e.g., 'binance', 'coinbase') | |
| symbols | No | Optional list of specific symbols to fetch |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"exchangeId": {
"description": "Exchange ID (e.g., 'binance', 'coinbase')",
"type": "string"
},
"symbols": {
"description": "Optional list of specific symbols to fetch",
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"exchangeId"
],
"type": "object"
}
Implementation Reference
- src/tools/market-tools.ts:92-117 (handler)The main handler function for the 'fetchTickers' MCP tool. It retrieves a public CCXT exchange instance and calls fetchTickers(symbols), returning the result as JSON or an error message.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)Zod input schema defining parameters: exchangeId (required string) and symbols (optional array of strings).{ 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)Direct registration of the 'fetchTickers' tool on the MCP server using server.tool(), including name, description, 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 in the CcxtMcpServer's registerTools method, which includes registration of fetchTickers.registerMarketTools(this.server, this);