get_external_market_data
Retrieve external market data for EDU tokens from centralized exchanges to monitor prices, trends, and trading activity effectively.
Instructions
Get external market data for EDU from centralized exchanges
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"properties": {},
"required": [],
"type": "object"
}
Implementation Reference
- src/external_market.ts:67-116 (handler)The main handler function that fetches EDU market data from CryptoCompare API, processes the response, and returns structured data including price, 24h changes, and metadata.* Fetch external market data for EDU from CryptoCompare */ export async function getExternalMarketData(): Promise<{ price: number; change24h: number; high24h: number; low24h: number; volume24h: number; marketCap: number; lastUpdate: string; source: string; }> { try { const { apiUrl, apiKey, symbols } = config; // Build request URL const url = `${apiUrl}?fsyms=${symbols.EDU}&tsyms=${symbols.USD}`; // Set up headers with API key if provided const headers: Record<string, string> = {}; if (apiKey) { headers['authorization'] = `Apikey ${apiKey}`; } // Make API request const response = await axios.get(url, { headers }); // Extract data const data = response.data; if (!data.RAW || !data.RAW[symbols.EDU] || !data.RAW[symbols.EDU][symbols.USD]) { throw new Error('Invalid response format from external API'); } const rawData = data.RAW[symbols.EDU][symbols.USD]; return { price: rawData.PRICE || 0, change24h: rawData.CHANGE24HOUR || 0, high24h: rawData.HIGH24HOUR || 0, low24h: rawData.LOW24HOUR || 0, volume24h: rawData.VOLUME24HOUR || 0, marketCap: rawData.MKTCAP || 0, lastUpdate: new Date(rawData.LASTUPDATE * 1000).toISOString(), source: 'CryptoCompare' }; } catch (error) { console.error('Error fetching external market data:', error); throw error; } }
- src/index.ts:1255-1283 (registration)MCP tool call handler that invokes the getExternalMarketData function from external_market module and returns the result as MCP content or handles errors.case 'get_external_market_data': { try { const data = await external_market.getExternalMarketData(); return { content: [ { type: 'text', text: JSON.stringify(data, null, 2), }, ], }; } catch (error) { console.error('Error getting external market data:', error); return { content: [ { type: 'text', text: JSON.stringify({ error: 'Failed to fetch external market data', message: (error as Error).message, note: 'You may need to update the external market API configuration' }, null, 2), }, ], isError: true, }; } }
- src/index.ts:612-619 (schema)Tool schema definition in the ListTools response, specifying the tool name, description, and empty input schema (no parameters required).name: 'get_external_market_data', description: 'Get external market data for EDU from centralized exchanges', inputSchema: { type: 'object', properties: {}, required: [], }, },
- src/index.ts:612-619 (registration)Registration of the tool in the ListToolsRequestSchema handler, making it discoverable by MCP clients.name: 'get_external_market_data', description: 'Get external market data for EDU from centralized exchanges', inputSchema: { type: 'object', properties: {}, required: [], }, },
- src/external_market.ts:62-64 (helper)Helper function to retrieve the current API configuration used by the market data fetcher.export function getConfig(): typeof config { return { ...config }; }