Skip to main content
Glama

fetchTokenPriceBySymbol

Retrieve current cryptocurrency prices by providing token symbols like BTC or ETH. This tool queries blockchain token data through Alchemy's MCP Server.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolsYesA list of blockchaintoken symbols to query. e.g. ["BTC", "ETH"]

Implementation Reference

  • index.ts:17-38 (registration)
    Registration of the fetchTokenPriceBySymbol tool, including Zod input schema and inline error-handling wrapper that delegates to alchemyApi.getTokenPriceBySymbol
    server.tool('fetchTokenPriceBySymbol', { symbols: z.array(z.string()).describe('A list of blockchaintoken symbols to query. e.g. ["BTC", "ETH"]'), }, async (params) => { try { const result = await alchemyApi.getTokenPriceBySymbol(params); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; } catch (error) { if (error instanceof Error) { console.error('Error in getTokenPriceBySymbol:', error); return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true }; } return { content: [{ type: "text", text: 'Unknown error occurred' }], isError: true }; } });
  • Core implementation of the token price fetching logic via Alchemy Prices API client, called by the tool handler
    async getTokenPriceBySymbol(params: TokenPriceBySymbol) { try { const client = createPricesClient(); const queryParams = new URLSearchParams(); params.symbols.forEach(symbol => { queryParams.append('symbols', symbol.toUpperCase()); }); const response = await client.get(`/by-symbol?${queryParams}`); return response.data; } catch (error) { console.error('Error fetching token prices:', error); throw error; } },
  • TypeScript interface defining the input shape for getTokenPriceBySymbol (matches the Zod schema)
    export interface TokenPriceBySymbol { symbols: string[]; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/alchemyplatform/alchemy-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server