UNPKG

@tamago-labs/xrpl-mcp

Version:

MCP server implementation for XRP Ledger

923 lines (892 loc) 29.7 kB
#!/usr/bin/env node "use strict"; var __defProp = Object.defineProperty; var __getOwnPropNames = Object.getOwnPropertyNames; var __esm = (fn, res) => function __init() { return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; }; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; // src/tools/dex/orderbook.ts var orderbook_exports = {}; __export(orderbook_exports, { getAccountOffers: () => getAccountOffers, getOrderBook: () => getOrderBook, getTickerInfo: () => getTickerInfo }); async function getOrderBook(agent, takerGets, takerPays, limit = 20) { try { const response = await agent.client.request({ command: "book_offers", taker_gets: takerGets, taker_pays: takerPays, limit }); return { offers: response.result.offers || [], ledger_current_index: response.result.ledger_current_index }; } catch (error) { throw new Error(`Failed to get order book: ${error instanceof Error ? error.message : "Unknown error"}`); } } async function getAccountOffers(agent, address) { try { const response = await agent.client.request({ command: "account_offers", account: address, ledger_index: "current" }); return response.result.offers || []; } catch (error) { throw new Error(`Failed to get account offers: ${error instanceof Error ? error.message : "Unknown error"}`); } } async function getTickerInfo(agent, takerGets, takerPays) { try { const orderBook = await getOrderBook(agent, takerGets, takerPays, 10); return { pair: `${takerGets.currency || "XRP"}/${takerPays.currency || "XRP"}`, orderBook: orderBook.offers, timestamp: (/* @__PURE__ */ new Date()).toISOString() }; } catch (error) { throw new Error(`Failed to get ticker info: ${error instanceof Error ? error.message : "Unknown error"}`); } } var init_orderbook = __esm({ "src/tools/dex/orderbook.ts"() { "use strict"; } }); // src/config.ts var getArgs = () => process.argv.reduce((args, arg) => { if (arg.slice(0, 2) === "--") { const longArg = arg.split("="); const longArgFlag = longArg[0].slice(2); const longArgValue = longArg.length > 1 ? longArg[1] : true; args[longArgFlag] = longArgValue; } else if (arg[0] === "-") { const flags = arg.slice(1).split(""); flags.forEach((flag) => { args[flag] = true; }); } return args; }, {}); function validateEnvironment() { const args = getArgs(); const hasPrivateKey = !!args?.xrpl_private_key; if (!hasPrivateKey) { throw new Error( "Missing required environment variable: XRPL_PRIVATE_KEY must be provided" ); } const hasXrplNetwork = !!args?.xrpl_network; if (!hasXrplNetwork) { throw new Error("Missing required environment variable: XRPL_NETWORK"); } } function getXrplConfig() { validateEnvironment(); const args = getArgs(); const currentEnv = { XRPL_PRIVATE_KEY: args?.xrpl_private_key, XRPL_NETWORK: args?.xrpl_network }; return { privateKey: currentEnv.XRPL_PRIVATE_KEY, network: currentEnv.XRPL_NETWORK || "testnet" }; } // src/index.ts var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js"); var import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js"); // src/mcp/xrpl/get_wallet_address_tool.ts var GetWalletAddressTool = { name: "xrpl_get_wallet_address", description: "Get the active wallet address", schema: {}, handler: async (agent, input) => { const walletAddress = await agent.getWalletAddress(); return { status: "success", walletAddress }; } }; // src/mcp/xrpl/get_account_info_tool.ts var import_zod = require("zod"); var GetAccountInfoTool = { name: "xrpl_get_account_info", description: "Get account information for a given address", schema: { address: import_zod.z.string().regex(/^r[a-zA-Z0-9]{24,34}$/).optional().describe("XRPL address to get info for (optional, defaults to wallet address)") }, handler: async (agent, input) => { try { const accountInfo = await agent.getAccountInfo(input.address); return { status: "success", accountInfo }; } catch (error) { return { status: "error", message: error instanceof Error ? error.message : "Unknown error occurred" }; } } }; // src/mcp/xrpl/get_balances_tool.ts var import_zod2 = require("zod"); var GetBalancesTool = { name: "xrpl_get_balances", description: "Get all token balances for a given address", schema: { address: import_zod2.z.string().regex(/^r[a-zA-Z0-9]{24,34}$/).optional().describe("XRPL address to get balances for (optional, defaults to wallet address)") }, handler: async (agent, input) => { try { const balances = await agent.getBalances(input.address); return { status: "success", balances }; } catch (error) { return { status: "error", message: error instanceof Error ? error.message : "Unknown error occurred" }; } } }; // src/mcp/xrpl/send_payment_tool.ts var import_zod3 = require("zod"); var SendPaymentTool = { name: "xrpl_send_payment", description: "Send XRP or tokens to another address", schema: { destination: import_zod3.z.string().regex(/^r[a-zA-Z0-9]{24,34}$/).describe("Destination XRPL address"), amount: import_zod3.z.union([ import_zod3.z.string().describe("Amount of XRP to send"), import_zod3.z.object({ currency: import_zod3.z.string(), value: import_zod3.z.string(), issuer: import_zod3.z.string().regex(/^r[a-zA-Z0-9]{24,34}$/) }) ]).describe("Amount to send (XRP as string or token object)"), destinationTag: import_zod3.z.number().int().min(0).max(4294967295).optional().describe("Optional destination tag") }, handler: async (agent, input) => { try { const result = await agent.sendPayment({ destination: input.destination, amount: input.amount, destinationTag: input.destinationTag }); return result; } catch (error) { return { status: "error", message: error instanceof Error ? error.message : "Unknown error occurred" }; } } }; // src/mcp/token/create_token_tool.ts var import_zod4 = require("zod"); var CreateTokenTool = { name: "xrpl_create_token", description: "Create a new token by setting account flags", schema: { currency: import_zod4.z.string().regex(/^[A-Z0-9]{3}$/).describe("Token currency code (3 characters)"), domain: import_zod4.z.string().max(256).optional().describe("Domain name for the token issuer"), emailHash: import_zod4.z.string().length(32).optional().describe("Email hash for the issuer (32 hex characters)"), transferRate: import_zod4.z.number().int().min(1e9).max(2e9).optional().describe("Transfer rate (fee) for the token (1000000000 = 0%, 1010000000 = 1%)"), requireAuth: import_zod4.z.boolean().default(false).describe("Require authorization for trust lines"), requireDest: import_zod4.z.boolean().default(false).describe("Require destination tag"), disallowXRP: import_zod4.z.boolean().default(false).describe("Disallow XRP payments"), globalFreeze: import_zod4.z.boolean().default(false).describe("Enable global freeze"), noFreeze: import_zod4.z.boolean().default(false).describe("Disable freeze functionality"), defaultRipple: import_zod4.z.boolean().default(false).describe("Enable default ripple") }, handler: async (agent, input) => { try { const result = await agent.createToken(input); return result; } catch (error) { return { status: "error", message: error instanceof Error ? error.message : "Unknown error occurred" }; } } }; // src/mcp/token/set_trust_line_tool.ts var import_zod5 = require("zod"); var SetTrustLineTool = { name: "xrpl_set_trust_line", description: "Set a trust line for a token", schema: { currency: import_zod5.z.string().regex(/^[A-Z0-9]{3}$/).describe("Currency code for the token (3 characters)"), issuer: import_zod5.z.string().regex(/^r[a-zA-Z0-9]{24,34}$/).describe("Token issuer address"), limit: import_zod5.z.string().regex(/^\d+(\.\d+)?$/).describe("Trust limit amount") }, handler: async (agent, input) => { try { const result = await agent.setTrustLine(input.currency, input.issuer, input.limit); return result; } catch (error) { return { status: "error", message: error instanceof Error ? error.message : "Unknown error occurred" }; } } }; // src/mcp/token/mint_nftoken_tool.ts var import_zod6 = require("zod"); var MintNFTokenTool = { name: "xrpl_mint_nftoken", description: "Mint a new NFToken", schema: { uri: import_zod6.z.string().url().max(512).optional().describe("URI for the NFToken metadata"), flags: import_zod6.z.number().int().min(0).max(15).optional().describe("NFToken flags (0-15)"), transferFee: import_zod6.z.number().int().min(0).max(5e4).optional().describe("Transfer fee (0-50000, representing 0-50%)"), taxon: import_zod6.z.number().int().min(0).max(4294967295).optional().describe("NFToken taxon") }, handler: async (agent, input) => { try { const result = await agent.mintNFToken(input); return result; } catch (error) { return { status: "error", message: error instanceof Error ? error.message : "Unknown error occurred" }; } } }; // src/mcp/token/burn_nftoken_tool.ts var import_zod7 = require("zod"); var BurnNFTokenTool = { name: "xrpl_burn_nftoken", description: "Burn an NFToken", schema: { nftokenID: import_zod7.z.string().regex(/^[A-F0-9]{64}$/i).describe("NFToken ID to burn (64 hex characters)") }, handler: async (agent, input) => { try { const result = await agent.burnNFToken(input.nftokenID); return result; } catch (error) { return { status: "error", message: error instanceof Error ? error.message : "Unknown error occurred" }; } } }; // src/mcp/transaction/create_offer_tool.ts var import_zod8 = require("zod"); var CreateOfferTool = { name: "xrpl_create_offer", description: "Create a trading offer on the DEX", schema: { takerGets: import_zod8.z.union([ import_zod8.z.string().describe("Amount of XRP in drops"), import_zod8.z.object({ currency: import_zod8.z.string().regex(/^[A-Z0-9]{3}$/), value: import_zod8.z.string().regex(/^\d+(\.\d+)?$/), issuer: import_zod8.z.string().regex(/^r[a-zA-Z0-9]{24,34}$/) }) ]).describe("What the taker gets"), takerPays: import_zod8.z.union([ import_zod8.z.string().describe("Amount of XRP in drops"), import_zod8.z.object({ currency: import_zod8.z.string().regex(/^[A-Z0-9]{3}$/), value: import_zod8.z.string().regex(/^\d+(\.\d+)?$/), issuer: import_zod8.z.string().regex(/^r[a-zA-Z0-9]{24,34}$/) }) ]).describe("What the taker pays"), expiration: import_zod8.z.number().int().min(0).optional().describe("Offer expiration time (XRPL timestamp)") }, handler: async (agent, input) => { try { const result = await agent.createOffer(input); return result; } catch (error) { return { status: "error", message: error instanceof Error ? error.message : "Unknown error occurred" }; } } }; // src/mcp/transaction/cancel_offer_tool.ts var import_zod9 = require("zod"); var CancelOfferTool = { name: "xrpl_cancel_offer", description: "Cancel an existing offer", schema: { offerSequence: import_zod9.z.number().int().positive().describe("Sequence number of the offer to cancel") }, handler: async (agent, input) => { try { const result = await agent.cancelOffer(input.offerSequence); return result; } catch (error) { return { status: "error", message: error instanceof Error ? error.message : "Unknown error occurred" }; } } }; // src/mcp/transaction/get_transaction_tool.ts var import_zod10 = require("zod"); var GetTransactionTool = { name: "xrpl_get_transaction", description: "Get transaction details by hash", schema: { hash: import_zod10.z.string().regex(/^[A-F0-9]{64}$/i).describe("Transaction hash (64 hex characters)") }, handler: async (agent, input) => { try { const transaction = await agent.getTransaction(input.hash); return { status: "success", transaction }; } catch (error) { return { status: "error", message: error instanceof Error ? error.message : "Unknown error occurred" }; } } }; // src/mcp/transaction/get_recent_transactions_tool.ts var import_zod11 = require("zod"); var GetRecentTransactionsTool = { name: "xrpl_get_recent_transactions", description: "Get recent transactions for an account", schema: { address: import_zod11.z.string().regex(/^r[a-zA-Z0-9]{24,34}$/).optional().describe("Account address (optional, defaults to wallet address)"), limit: import_zod11.z.number().int().min(1).max(100).default(10).describe("Number of transactions to retrieve (default: 10, max: 100)") }, handler: async (agent, input) => { try { const transactions = await agent.getRecentTransactions(input.address, input.limit); return { status: "success", transactions }; } catch (error) { return { status: "error", message: error instanceof Error ? error.message : "Unknown error occurred" }; } } }; // src/mcp/dex/get_order_book_tool.ts var import_zod12 = require("zod"); var GetOrderBookTool = { name: "xrpl_get_order_book", description: "Get order book for a trading pair", schema: { takerGets: import_zod12.z.union([ import_zod12.z.literal("XRP").describe("XRP currency"), import_zod12.z.object({ currency: import_zod12.z.string().regex(/^[A-Z0-9]{3}$/), issuer: import_zod12.z.string().regex(/^r[a-zA-Z0-9]{24,34}$/) }) ]).describe("Base currency (what taker gets)"), takerPays: import_zod12.z.union([ import_zod12.z.literal("XRP").describe("XRP currency"), import_zod12.z.object({ currency: import_zod12.z.string().regex(/^[A-Z0-9]{3}$/), issuer: import_zod12.z.string().regex(/^r[a-zA-Z0-9]{24,34}$/) }) ]).describe("Quote currency (what taker pays)"), limit: import_zod12.z.number().int().min(1).max(100).default(20).describe("Number of offers to retrieve (default: 20, max: 100)") }, handler: async (agent, input) => { try { const { getOrderBook: getOrderBook2 } = await Promise.resolve().then(() => (init_orderbook(), orderbook_exports)); const takerGets = input.takerGets === "XRP" ? { currency: "XRP" } : input.takerGets; const takerPays = input.takerPays === "XRP" ? { currency: "XRP" } : input.takerPays; const orderBook = await getOrderBook2(agent, takerGets, takerPays, input.limit); return { status: "success", orderBook }; } catch (error) { return { status: "error", message: error instanceof Error ? error.message : "Unknown error occurred" }; } } }; // src/mcp/dex/get_account_offers_tool.ts var import_zod13 = require("zod"); var GetAccountOffersTool = { name: "xrpl_get_account_offers", description: "Get all active offers for an account", schema: { address: import_zod13.z.string().regex(/^r[a-zA-Z0-9]{24,34}$/).optional().describe("Account address (optional, defaults to wallet address)") }, handler: async (agent, input) => { try { const { getAccountOffers: getAccountOffers2 } = await Promise.resolve().then(() => (init_orderbook(), orderbook_exports)); const offers = await getAccountOffers2(agent, input.address || agent.walletAddress); return { status: "success", offers }; } catch (error) { return { status: "error", message: error instanceof Error ? error.message : "Unknown error occurred" }; } } }; // src/mcp/index.ts var XrplMcpTools = { // XRPL Core "GetWalletAddressTool": GetWalletAddressTool, "GetAccountInfoTool": GetAccountInfoTool, "GetBalancesTool": GetBalancesTool, "SendPaymentTool": SendPaymentTool, // Token Management "CreateTokenTool": CreateTokenTool, "SetTrustLineTool": SetTrustLineTool, "MintNFTokenTool": MintNFTokenTool, "BurnNFTokenTool": BurnNFTokenTool, // Trading & Transactions "CreateOfferTool": CreateOfferTool, "CancelOfferTool": CancelOfferTool, "GetTransactionTool": GetTransactionTool, "GetRecentTransactionsTool": GetRecentTransactionsTool, // DEX & Order Book "GetOrderBookTool": GetOrderBookTool, "GetAccountOffersTool": GetAccountOffersTool }; // src/agent/index.ts var import_xrpl = require("xrpl"); // src/tools/xrpl/account.ts async function getAccountInfo(agent, address) { try { const response = await agent.client.request({ command: "account_info", account: address, ledger_index: "current" }); return { account: response.result.account_data.Account, balance: response.result.account_data.Balance, flags: response.result.account_data.Flags, ledgerEntryType: response.result.account_data.LedgerEntryType, ownerCount: response.result.account_data.OwnerCount, previousTxnID: response.result.account_data.PreviousTxnID, previousTxnLgrSeq: response.result.account_data.PreviousTxnLgrSeq, sequence: response.result.account_data.Sequence }; } catch (error) { throw new Error(`Failed to get account info: ${error instanceof Error ? error.message : "Unknown error"}`); } } // src/tools/xrpl/balance.ts async function getBalances(agent, address) { try { const balances = []; const accountInfo = await agent.client.request({ command: "account_info", account: address, ledger_index: "current" }); balances.push({ currency: "XRP", value: agent.dropsToXrp(accountInfo.result.account_data.Balance) }); try { const trustLines = await agent.client.request({ command: "account_lines", account: address, ledger_index: "current" }); if (trustLines.result.lines) { for (const line of trustLines.result.lines) { balances.push({ currency: line.currency, value: line.balance, issuer: line.account }); } } } catch (error) { } return balances; } catch (error) { throw new Error(`Failed to get balances: ${error instanceof Error ? error.message : "Unknown error"}`); } } // src/tools/xrpl/payment.ts async function sendPayment(agent, params) { try { const payment = { TransactionType: "Payment", Account: agent.walletAddress, Destination: params.destination, Amount: typeof params.amount === "string" ? agent.xrpToDrops(params.amount) : params.amount, ...params.destinationTag && { DestinationTag: params.destinationTag } }; const prepared = await agent.client.autofill(payment); const signed = agent.wallet.sign(prepared); const result = await agent.client.submitAndWait(signed.tx_blob); return { hash: result.result.hash, status: result.result.meta?.TransactionResult || "unknown", result: result.result }; } catch (error) { return { status: "error", message: error instanceof Error ? error.message : "Unknown error occurred" }; } } // src/tools/token/create.ts async function createToken(agent, params) { try { const accountSet = { TransactionType: "AccountSet", Account: agent.walletAddress, ...params.domain && { Domain: Buffer.from(params.domain).toString("hex").toUpperCase() }, ...params.emailHash && { EmailHash: params.emailHash }, ...params.messageKey && { MessageKey: params.messageKey }, ...params.transferRate && { TransferRate: params.transferRate }, ...params.tickSize && { TickSize: params.tickSize } }; let setFlag = 0; let clearFlag = 0; if (params.requireAuth) setFlag |= 2; if (params.requireDest) setFlag |= 1; if (params.disallowXRP) setFlag |= 8; if (params.globalFreeze) setFlag |= 128; if (params.noFreeze) setFlag |= 64; if (params.defaultRipple) setFlag |= 131072; if (setFlag > 0) accountSet.SetFlag = setFlag; if (clearFlag > 0) accountSet.ClearFlag = clearFlag; const prepared = await agent.client.autofill(accountSet); const signed = agent.wallet.sign(prepared); const result = await agent.client.submitAndWait(signed.tx_blob); return { hash: result.result.hash, status: result.result.meta?.TransactionResult || "unknown", result: result.result }; } catch (error) { return { status: "error", message: error instanceof Error ? error.message : "Unknown error occurred" }; } } // src/tools/token/trustline.ts async function setTrustLine(agent, currency, issuer, limit) { try { const trustSet = { TransactionType: "TrustSet", Account: agent.walletAddress, LimitAmount: { currency, issuer, value: limit } }; const prepared = await agent.client.autofill(trustSet); const signed = agent.wallet.sign(prepared); const result = await agent.client.submitAndWait(signed.tx_blob); return { hash: result.result.hash, status: result.result.meta?.TransactionResult || "unknown", result: result.result }; } catch (error) { return { status: "error", message: error instanceof Error ? error.message : "Unknown error occurred" }; } } // src/tools/token/nft.ts async function mintNFToken(agent, params) { try { const nftokenMint = { TransactionType: "NFTokenMint", Account: agent.walletAddress, ...params.uri && { URI: Buffer.from(params.uri).toString("hex").toUpperCase() }, ...params.flags && { Flags: params.flags }, ...params.transferFee && { TransferFee: params.transferFee }, ...params.taxon && { NFTokenTaxon: params.taxon } }; const prepared = await agent.client.autofill(nftokenMint); const signed = agent.wallet.sign(prepared); const result = await agent.client.submitAndWait(signed.tx_blob); return { hash: result.result.hash, status: result.result.meta?.TransactionResult || "unknown", result: result.result }; } catch (error) { return { status: "error", message: error instanceof Error ? error.message : "Unknown error occurred" }; } } async function burnNFToken(agent, nftokenID) { try { const nftokenBurn = { TransactionType: "NFTokenBurn", Account: agent.walletAddress, NFTokenID: nftokenID }; const prepared = await agent.client.autofill(nftokenBurn); const signed = agent.wallet.sign(prepared); const result = await agent.client.submitAndWait(signed.tx_blob); return { hash: result.result.hash, status: result.result.meta?.TransactionResult || "unknown", result: result.result }; } catch (error) { return { status: "error", message: error instanceof Error ? error.message : "Unknown error occurred" }; } } // src/tools/transaction/offer.ts async function createOffer(agent, params) { try { const offerCreate = { TransactionType: "OfferCreate", Account: agent.walletAddress, TakerGets: params.takerGets, TakerPays: params.takerPays, ...params.expiration && { Expiration: params.expiration }, ...params.offerSequence && { OfferSequence: params.offerSequence } }; const prepared = await agent.client.autofill(offerCreate); const signed = agent.wallet.sign(prepared); const result = await agent.client.submitAndWait(signed.tx_blob); return { hash: result.result.hash, status: result.result.meta?.TransactionResult || "unknown", result: result.result }; } catch (error) { return { status: "error", message: error instanceof Error ? error.message : "Unknown error occurred" }; } } async function cancelOffer(agent, offerSequence) { try { const offerCancel = { TransactionType: "OfferCancel", Account: agent.walletAddress, OfferSequence: offerSequence }; const prepared = await agent.client.autofill(offerCancel); const signed = agent.wallet.sign(prepared); const result = await agent.client.submitAndWait(signed.tx_blob); return { hash: result.result.hash, status: result.result.meta?.TransactionResult || "unknown", result: result.result }; } catch (error) { return { status: "error", message: error instanceof Error ? error.message : "Unknown error occurred" }; } } // src/tools/transaction/management.ts async function getTransactionInfo(agent, hash) { try { const response = await agent.client.request({ command: "tx", transaction: hash }); return response.result; } catch (error) { throw new Error(`Failed to get transaction info: ${error instanceof Error ? error.message : "Unknown error"}`); } } async function getAccountTransactions(agent, address, limit = 10) { try { const response = await agent.client.request({ command: "account_tx", account: address, ledger_index_min: -1, ledger_index_max: -1, limit, binary: false }); return response.result.transactions || []; } catch (error) { throw new Error(`Failed to get account transactions: ${error instanceof Error ? error.message : "Unknown error"}`); } } // src/agent/index.ts init_orderbook(); // src/constants.ts var NETWORKS = { testnet: "wss://s.altnet.rippletest.net:51233", mainnet: "wss://xrplcluster.com", devnet: "wss://s.devnet.rippletest.net:51233" }; // src/agent/index.ts var Agent = class { constructor() { const config = getXrplConfig(); const serverUrl = NETWORKS[config.network]; this.client = new import_xrpl.Client(serverUrl); this.network = config.network; this.wallet = import_xrpl.Wallet.fromSeed(config.privateKey); this.walletAddress = this.wallet.address; } async connect() { if (!this.client.isConnected()) { await this.client.connect(); } } async disconnect() { if (this.client.isConnected()) { await this.client.disconnect(); } } async getWalletAddress() { return this.walletAddress; } async getAccountInfo(address) { await this.connect(); return getAccountInfo(this, address || this.walletAddress); } async getBalances(address) { await this.connect(); return getBalances(this, address || this.walletAddress); } async sendPayment(params) { await this.connect(); return sendPayment(this, params); } async createToken(params) { await this.connect(); return createToken(this, params); } async setTrustLine(currency, issuer, limit) { await this.connect(); return setTrustLine(this, currency, issuer, limit); } async mintNFToken(params) { await this.connect(); return mintNFToken(this, params); } async burnNFToken(nftokenID) { await this.connect(); return burnNFToken(this, nftokenID); } async createOffer(params) { await this.connect(); return createOffer(this, params); } async cancelOffer(offerSequence) { await this.connect(); return cancelOffer(this, offerSequence); } async getTransaction(hash) { await this.connect(); return getTransactionInfo(this, hash); } async getRecentTransactions(address, limit) { await this.connect(); return getAccountTransactions(this, address || this.walletAddress, limit || 10); } // DEX methods async getOrderBook(takerGets, takerPays, limit) { await this.connect(); return getOrderBook(this, takerGets, takerPays, limit); } async getAccountOffers(address) { await this.connect(); return getAccountOffers(this, address || this.walletAddress); } // Utility methods xrpToDrops(xrp) { return (0, import_xrpl.xrpToDrops)(xrp); } dropsToXrp(drops) { return `${(0, import_xrpl.dropsToXrp)(drops)}`; } }; // src/index.ts function createMcpServer(agent) { const server = new import_mcp.McpServer({ name: "xrpl-mcp", version: "0.1.0" }); for (const [_key, tool] of Object.entries(XrplMcpTools)) { server.tool(tool.name, tool.description, tool.schema, async (params) => { try { const result = await tool.handler(agent, params); return { content: [ { type: "text", text: JSON.stringify(result, null, 2) } ] }; } catch (error) { console.error("error", error); return { isError: true, content: [ { type: "text", text: error instanceof Error ? error.message : "Unknown error occurred" } ] }; } }); } return server; } async function main() { try { validateEnvironment(); const myAgent = new Agent(); const server = createMcpServer(myAgent); const transport = new import_stdio.StdioServerTransport(); await server.connect(transport); console.error("XRPL MCP server is running..."); } catch (error) { console.error("Error starting MCP server:", error); process.exit(1); } } main(); //# sourceMappingURL=index.js.map