UNPKG

@mseep/coincap-mcp

Version:

A MCP server to get crypto prices from coincap

33 lines (32 loc) 986 B
import { BITCOIN_PRICE_URL } from "../constants.js"; import { BaseToolImplementation } from "./BaseTool.js"; class BitcoinPriceTool extends BaseToolImplementation { name = "bitcoin_price"; toolDefinition = { name: this.name, description: "Get realtime bitcoin price", inputSchema: { type: "object", }, }; toolCall = async () => { try { const response = await fetch(BITCOIN_PRICE_URL); if (!response.ok) { throw new Error("Error fetching coincap data"); } const body = await response.json(); return { content: [{ type: "text", text: `${JSON.stringify(body.data)}` }], }; } catch (error) { return { content: [ { type: "error", text: JSON.stringify(error.message) }, ], }; } }; } export default BitcoinPriceTool;