fetchTicker
Retrieve real-time ticker data for specified trading pairs on supported exchanges. Input exchange ID and symbol to access pricing, volume, and market information for informed cryptocurrency trading decisions.
Instructions
Fetch ticker information for a symbol on an exchange
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| exchangeId | Yes | Exchange ID (e.g., 'binance', 'coinbase') | |
| symbol | Yes | Trading symbol (e.g., 'BTC/USDT') |
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"
},
"symbol": {
"description": "Trading symbol (e.g., 'BTC/USDT')",
"type": "string"
}
},
"required": [
"exchangeId",
"symbol"
],
"type": "object"
}
Implementation Reference
- src/tools/market-tools.ts:56-82 (handler)Handler function that fetches ticker data from the CCXT exchange instance for the specified symbol and returns JSON-formatted response or error.async ({ exchangeId, symbol }) => { try { // 공개 인스턴스 사용 const exchange = ccxtServer.getPublicExchangeInstance(exchangeId); const ticker = await exchange.fetchTicker(symbol); return { content: [ { type: "text", text: JSON.stringify(ticker, null, 2) } ] }; } catch (error) { return { content: [ { type: "text", text: `Error fetching ticker: ${(error as Error).message}` } ], isError: true }; } } );
- src/tools/market-tools.ts:52-55 (schema)Input schema using Zod validators for 'exchangeId' and 'symbol' parameters.{ exchangeId: z.string().describe("Exchange ID (e.g., 'binance', 'coinbase')"), symbol: z.string().describe("Trading symbol (e.g., 'BTC/USDT')") },
- src/tools/market-tools.ts:49-82 (registration)Full server.tool call registering the 'fetchTicker' MCP tool, including name, description, input schema, and handler.server.tool( "fetchTicker", "Fetch ticker information for a symbol on an exchange", { exchangeId: z.string().describe("Exchange ID (e.g., 'binance', 'coinbase')"), symbol: z.string().describe("Trading symbol (e.g., 'BTC/USDT')") }, async ({ exchangeId, symbol }) => { try { // 공개 인스턴스 사용 const exchange = ccxtServer.getPublicExchangeInstance(exchangeId); const ticker = await exchange.fetchTicker(symbol); return { content: [ { type: "text", text: JSON.stringify(ticker, null, 2) } ] }; } catch (error) { return { content: [ { type: "text", text: `Error fetching ticker: ${(error as Error).message}` } ], isError: true }; } } );
- src/server.ts:372-372 (registration)Top-level call to registerMarketTools in CcxtMcpServer's registerTools method, which registers the fetchTicker tool among market tools.registerMarketTools(this.server, this);