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
| Name | Required | Description | Default |
|---|---|---|---|
| coin_id | Yes | ||
| vs_currency | Yes |
Implementation Reference
- src/apis/crypto/coingecko.ts:51-56 (handler)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); },
- src/apis/crypto/coingecko.ts:26-33 (schema)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"], },
- src/apis/crypto/coingecko.ts:22-67 (registration)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); }, }, }; }
- src/tools/register.ts:32-32 (registration)Includes the CoinGecko registration in the array of all tool registrations within registerAllTools.registerCoinGecko(),
- src/apis/crypto/coingecko.ts:9-10 (helper)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 } });