UNPKG

asset-price-mcp

Version:

An MCP-compatible service that provides real-time asset prices including precious metals, cryptocurrencies, and more

31 lines (30 loc) 1.09 kB
export const registerListAssetsTool = (server, services) => { server.tool("list_assets", "List all supported assets available for price queries", {}, async () => { const allAssets = []; for (const service of services) { try { const assets = await service.getSupportedAssets(); // Add source info or handle duplicates? // For now, just concat and maybe dedupe by symbol allAssets.push(...assets); } catch (error) { console.error(`Failed to fetch assets from ${service.getName()}:`, error); } } // Deduplicate by symbol const seen = new Set(); const uniqueAssets = allAssets.filter(asset => { if (seen.has(asset.symbol)) return false; seen.add(asset.symbol); return true; }); return { content: [{ type: "text", text: JSON.stringify(uniqueAssets, null, 2) }] }; }); };