UNPKG

@covalenthq/goldrush-mcp-server

Version:

GoldRush MCP Server for interacting with Covalent GoldRush API

156 lines 5.75 kB
import { validQuoteValues } from "../utils/constants.js"; import { PARAM_DESCRIPTIONS, TOOL_DESCRIPTIONS, } from "../utils/generated-descriptions.js"; import { stringifyWithBigInt } from "../utils/helpers.js"; import { ChainName, } from "@covalenthq/client-sdk"; import { z } from "zod"; export function addAllChainsServiceTools(server, goldRushClient) { server.tool("multichain_transactions", TOOL_DESCRIPTIONS["multichain_transactions"], { chains: z .array(z.union([ z.enum(Object.values(ChainName)), z.number(), ])) .optional() .describe(PARAM_DESCRIPTIONS["multichain_transactions"]["chains"]), addresses: z .array(z.string()) .optional() .describe(PARAM_DESCRIPTIONS["multichain_transactions"]["addresses"]), limit: z .number() .optional() .default(10) .describe(PARAM_DESCRIPTIONS["multichain_transactions"]["limit"]), before: z .string() .optional() .describe(PARAM_DESCRIPTIONS["multichain_transactions"]["before"]), after: z .string() .optional() .describe(PARAM_DESCRIPTIONS["multichain_transactions"]["after"]), withLogs: z .boolean() .optional() .default(false) .describe(PARAM_DESCRIPTIONS["multichain_transactions"]["withLogs"]), withDecodedLogs: z .boolean() .optional() .default(false) .describe(PARAM_DESCRIPTIONS["multichain_transactions"]["withDecodedLogs"]), quoteCurrency: z .enum(Object.values(validQuoteValues)) .optional() .describe(PARAM_DESCRIPTIONS["multichain_transactions"]["quoteCurrency"]), }, async (params) => { try { const response = await goldRushClient.AllChainsService.getMultiChainMultiAddressTransactions({ chains: params.chains, addresses: params.addresses, limit: params.limit, before: params.before, after: params.after, withLogs: params.withLogs, withDecodedLogs: params.withDecodedLogs, quoteCurrency: params.quoteCurrency, }); return { content: [ { type: "text", text: stringifyWithBigInt(response.data), }, ], }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error}` }], isError: true, }; } }); server.tool("multichain_balances", TOOL_DESCRIPTIONS["multichain_balances"], { walletAddress: z .string() .describe(PARAM_DESCRIPTIONS["multichain_balances"]["walletAddress"]), quoteCurrency: z .enum(Object.values(validQuoteValues)) .optional() .describe(PARAM_DESCRIPTIONS["multichain_balances"]["quoteCurrency"]), before: z .string() .optional() .describe(PARAM_DESCRIPTIONS["multichain_balances"]["before"]), limit: z .number() .optional() .default(10) .describe(PARAM_DESCRIPTIONS["multichain_balances"]["limit"]), chains: z .array(z.union([ z.enum(Object.values(ChainName)), z.number(), ])) .optional() .describe(PARAM_DESCRIPTIONS["multichain_balances"]["chains"]), cutoffTimestamp: z .number() .optional() .describe(PARAM_DESCRIPTIONS["multichain_balances"]["cutoffTimestamp"]), }, async (params) => { try { const response = await goldRushClient.AllChainsService.getMultiChainBalances(params.walletAddress, { quoteCurrency: params.quoteCurrency, before: params.before, limit: params.limit, chains: params.chains, cutoffTimestamp: params.cutoffTimestamp, }); return { content: [ { type: "text", text: stringifyWithBigInt(response.data), }, ], }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error}` }], isError: true, }; } }); server.tool("multichain_address_activity", TOOL_DESCRIPTIONS["multichain_address_activity"], { walletAddress: z .string() .describe(PARAM_DESCRIPTIONS["multichain_address_activity"]["walletAddress"]), testnets: z .boolean() .optional() .default(false) .describe(PARAM_DESCRIPTIONS["multichain_address_activity"]["testnets"]), }, async (params) => { try { const response = await goldRushClient.AllChainsService.getAddressActivity(params.walletAddress, { testnets: params.testnets }); return { content: [ { type: "text", text: stringifyWithBigInt(response.data), }, ], }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error}` }], isError: true, }; } }); } //# sourceMappingURL=AllChainsService.js.map