Skip to main content
Glama

get_coin_price

Retrieve current cryptocurrency prices by specifying coin identifier and target currency. This tool provides real-time market data for informed trading decisions.

Instructions

Get current price for a coin in a given currency

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
coin_idYes
vs_currencyYes

Implementation Reference

  • The asynchronous handler function that implements the core logic for the get_coin_price tool. It extracts and validates the coin_id and vs_currency arguments, then calls the CoinGeckoClient's getPrice method.
    async get_coin_price(args: Record<string, unknown>) { const coinId = String(args.coin_id || ""); const vsCurrency = String(args.vs_currency || ""); if (!coinId || !vsCurrency) throw new Error("coin_id and vs_currency are required"); return client.getPrice(coinId, vsCurrency); },
  • The schema definition for the get_coin_price tool, specifying the name, description, and input schema requiring coin_id and vs_currency as strings.
    { name: "get_coin_price", description: "Get current price for a coin in a given currency", inputSchema: { type: "object", properties: { coin_id: { type: "string" }, vs_currency: { type: "string" } }, required: ["coin_id", "vs_currency"], },
  • The registerCoinGecko function that returns a ToolRegistration object containing the tool schemas and handlers for CoinGecko API tools, including get_coin_price.
    export function registerCoinGecko(): ToolRegistration { const client = new CoinGeckoClient(); return { tools: [ { name: "get_coin_price", description: "Get current price for a coin in a given currency", inputSchema: { type: "object", properties: { coin_id: { type: "string" }, vs_currency: { type: "string" } }, required: ["coin_id", "vs_currency"], }, }, { name: "get_trending_coins", description: "Get trending coins on CoinGecko", inputSchema: { type: "object", properties: {} }, }, { name: "get_market_data", description: "Get market data for a coin", inputSchema: { type: "object", properties: { coin_id: { type: "string" } }, required: ["coin_id"], }, }, ], handlers: { async get_coin_price(args: Record<string, unknown>) { const coinId = String(args.coin_id || ""); const vsCurrency = String(args.vs_currency || ""); if (!coinId || !vsCurrency) throw new Error("coin_id and vs_currency are required"); return client.getPrice(coinId, vsCurrency); }, async get_trending_coins() { return client.getTrending(); }, async get_market_data(args: Record<string, unknown>) { const coinId = String(args.coin_id || ""); if (!coinId) throw new Error("coin_id is required"); return client.getMarketData(coinId); }, }, }; }
  • Includes the CoinGecko registration in the array of all tool registrations within registerAllTools.
    registerCoinGecko(),
  • Helper method in CoinGeckoClient that makes the API request to retrieve the coin price.
    getPrice(coinId: string, vsCurrency: string) { return this.request(`/simple/price`, { query: { ids: coinId, vs_currencies: vsCurrency } });

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/TaylorChen/muti-mcps'

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