UNPKG

@covalenthq/goldrush-mcp-server

Version:

GoldRush MCP Server for interacting with Covalent GoldRush API

83 lines 3.24 kB
import { validQuoteValues } from "../utils/constants.js"; import { TOOL_DESCRIPTIONS, PARAM_DESCRIPTIONS, } from "../utils/generated-descriptions.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", TOOL_DESCRIPTIONS["historical_token_prices"], { chainName: z .enum(Object.values(ChainName)) .describe(PARAM_DESCRIPTIONS["historical_token_prices"]["chainName"]), quoteCurrency: z .enum(Object.values(validQuoteValues)) .describe(PARAM_DESCRIPTIONS["historical_token_prices"]["quoteCurrency"]), contractAddress: z .string() .describe(PARAM_DESCRIPTIONS["historical_token_prices"]["contractAddress"]), from: z .string() .describe(PARAM_DESCRIPTIONS["historical_token_prices"]["from"]), to: z .string() .describe(PARAM_DESCRIPTIONS["historical_token_prices"]["to"]), pricesAtAsc: z .boolean() .optional() .describe(PARAM_DESCRIPTIONS["historical_token_prices"]["pricesAtAsc"]), }, 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", TOOL_DESCRIPTIONS["pool_spot_prices"], { chainName: z .enum(Object.values(ChainName)) .describe(PARAM_DESCRIPTIONS["pool_spot_prices"]["chainName"]), contractAddress: z .string() .describe(PARAM_DESCRIPTIONS["pool_spot_prices"]["contractAddress"]), quoteCurrency: z .enum(Object.values(validQuoteValues)) .optional() .describe(PARAM_DESCRIPTIONS["pool_spot_prices"]["quoteCurrency"]), }, 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