UNPKG

@covalenthq/goldrush-mcp-server

Version:

GoldRush MCP Server for interacting with Covalent GoldRush API

70 lines 3.08 kB
import { validQuoteValues } from "../utils/constants.js"; import { stringifyWithBigInt } from "../utils/helpers.js"; import { ChainName, } from "@covalenthq/client-sdk"; import { z } from "zod"; export function addPricingServiceTools(server, goldRushClient) { server.tool("historical_token_prices", "Commonly used to get historic prices of a token between date ranges. Supports native tokens.\n" + "Required: chainName (blockchain network), quoteCurrency (price currency), contractAddress (token contract), from (start date YYYY-MM-DD), to (end date YYYY-MM-DD).\n" + "Optional: pricesAtAsc (set to true for chronological ascending order, default is false for descending order).\n" + "Returns historical token prices for the specified time range.", { chainName: z.enum(Object.values(ChainName)), quoteCurrency: z.enum(Object.values(validQuoteValues)), contractAddress: z.string(), from: z.string(), to: z.string(), pricesAtAsc: z.boolean().optional(), }, async (params) => { try { const response = await goldRushClient.PricingService.getTokenPrices(params.chainName, params.quoteCurrency, params.contractAddress, { from: params.from, to: params.to, pricesAtAsc: params.pricesAtAsc, }); return { content: [ { type: "text", text: stringifyWithBigInt(response.data), }, ], }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error}` }], isError: true, }; } }); server.tool("pool_spot_prices", "Get the spot token pair prices for a specified pool contract address. Supports pools on Uniswap V2, V3 and their forks.\n" + "Required: chainName (blockchain network), contractAddress (pool contract address).\n" + "Optional: quoteCurrency (price currency) for value conversion.\n" + "Returns spot token pair prices with pool details and token metadata.", { chainName: z.enum(Object.values(ChainName)), contractAddress: z.string(), quoteCurrency: z .enum(Object.values(validQuoteValues)) .optional(), }, async (params) => { try { const response = await goldRushClient.PricingService.getPoolSpotPrices(params.chainName, params.contractAddress, { quoteCurrency: params.quoteCurrency, }); return { content: [ { type: "text", text: stringifyWithBigInt(response.data), }, ], }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error}` }], isError: true, }; } }); } //# sourceMappingURL=PricingService.js.map